Python runs on an android system

Source: Internet
Author: User
Tags glob

Download Scripting Layer for Android (SL4A)

https://github.com/damonkohler/sl4a

https://www.tutorialspoint.com/sl4a/

Https://mafiadoc.com/python-for-android-documentation_59bd673b1723ddb63c355d46.html

Pydev Features and usage examples

http://blog.csdn.net/lainegates/article/details/8445241

Python script file packaged as executable py2exe download URL http://www.py2exe.org/

Python Module Release steps:

First, the module

1. Import Module

1 Import Module1,mudule2 ...

2. From...import ... Import Module

Import the specified content

1 from modname import name1[, name2[, ... Namen]]

Import All content

1 from modname Import *

This kind of import method will have the risk of duplicate name, should pay attention to when use.

3. __all__ variables in the module

Used to restrict what is imported when importing from XXX import *. No longer __all__ the contents of this list will not be imported.

1 __all__ = [' name1 ', ' name2 ', ...]

Second, the package

The package organizes the associated modules together, put them in the same folder, and creates a name file in this folder __init__.py , so this folder is called包。

In the __init__.py file, define a __all__ variable that controls the module imported from the package name import *. You can also use the Import module in __init__.py, which mobule the same as the module name in the __all__ variable, in the same way as __all__.

Third, the module release

1. Create a setup.py file

1.  2├──setup.py 3├──suba 4│   ├──aa.py 5│   ├──bb.py 6│   └──__init__.py 7└──subb 8     ├──cc.py 9     ├── Dd.py10     └──__init__.py

2. setup.py file

1 from Distutils.core import setup2 3 Setup (name= "YourName", version= "1.0", description= "Your module", author= "You", Py_m odules=[' Suba.aa ', ' suba.bb ', ' subb.cc ', ' subb.dd '])

3. Building Modules

1 python setup.py Build
1. 2├──build 3│       | 4│       ├──suba 5│       │   ├──aa.py 6│       │   ├──bb.py 7│       │   └──__init__.p Y 8│       └──subb 9│           ├──cc.py10│           ├──dd.py11│           └──__init__.py

4. Generate a Release archive package

1 python setup.py sdist
1├──dist2│   └──yourname-1.0.tar.gz

5. Installation

    1. Find the module's compression package
    2. Extract
    3. Go to Folder
    4. Execute commandpython setup.py install --prefix=安装路径

This will be installed under the Install_dir\lib\site-packages

6. Referencing in the program

In the program, use the from import to complete the installation of the module

from 模块名 import 模块名或者*

The correct way to import modules from other internal package within a Python project

http://blog.csdn.net/luo123n/article/details/49849649

Convert a python file into an executable. exe file, using the Py2exe tool to convert

1. Download Py2exe

2. Create a mysetup.py file in the directory where the Python file is located, with the following contents:

#-*-Coding:utf-8-*-
‘‘‘
@author:
‘‘‘

From Distutils.core Import Setup
Import Py2exe

#setup (console=["longpresspowerkeytest.py", "enterengineermode.py"],options={"Py2exe": {"includes": ["ElementC14N "]}})
#setup (console=["longpresspowerkeytest.py", "enterengineermode.py"])

Setup (windows=["longpresspowerkeytest.py", "enterengineermode.py"])

longpresspowerkeytest.py and enterengineermode.py are Python files that need to be converted, in which console is the console program, and Windows is an Image interface program

or Setup (console=[r ' e:/hello.py ')

Specify the absolute path to the Python file

3. In Windows command line terminal

Python mysetup.py Py2exe

This generates the dist and build directory in the directory where the script is located, dist the next generation of the executable file.

or Python e:\setup.py py2exe

Based on Absolute path

4, Run Dist executable file, where Dist is the release of the required files, build is an intermediate file, not required.

5, Python mysetup.py py2exe--help can see the parameters of the command band

6. Specify Additional Files

Setup (console=["helloworld.py"),
data_files=[("bitmaps",
["Bm/large.gif", "Bm/small.gif"]),
("Fonts",
Glob.glob ("Fonts\\*.fnt"))],
)

Description: The Data_files option creates a subdirectory dist\bitmaps that contains two. gif files, and a subdirectory dist\fonts that contains all the. fnt files.

Using Pyinstaller to convert a python file to an executable file

1. Install pip, download path

Https://pypi.python.org/pypi/pip#downloads

Pip and Setuptools is included with Python >=3.4 and >=2.7.9

Pip is a python-dependent, install PIP, download Pip's tar package to local and unzip, this tar.gz format is Windows and Linux generic package, quite Linux under Yum.

2. Unpack the downloaded package

Execute python setup.py Install

Add the PIP to the environment variable, and in the path C:\Python27\Scripts

3. CMD Terminal run PIP list

First I generally use is python27, official website download Python27msi installs WINDOW7 64 bit, already brought the PIP and Easy_install

But I don't know how to install the WHL directory,

After searching, we found that the PIP and Easy_install were added to the environment variable, i.e. C:\Python27\Scripts

See https://www.cnblogs.com/2589-spark/p/4501816.html

Installing Pywin32

Can download PYWIN32?223?CP35?CP35M?WIN_AMD64.WHL

Download Path https://www.lfd.uci.edu/~gohlke/pythonlibs/#pip

Run pip install ***.WHL at terminal

or use the command to install PIP install Pywin32

4, Installation Pyinstaller

Https://www.cnblogs.com/gopythoner/p/6337543.html

https://pypi.python.org/pypi/PyInstaller/3.0

Can download Pyinstaller package decompression, run in the unzipped directory

Python seteup.py Install

Or use PIP to install

Pip Install Pyinstaller

5. Using Pyinstaller

1. Pyinstaller packaging method installed using download and installation

Place the files that need to be packaged in the extracted Pyinstaller folder, open the cmd window, switch the path to the current path, open the command prompt, and enter the following (the last file name):

      • Python pyinstaller.py-f myfile.py
2. Pyinstaller packaging method installed with Pip method

Open the cmd window, switch the path to the path where the file is located (wherever the file is placed) open a command prompt, enter the following (the last file name):

      • Pyinstaller-f myfile.py

3, the meaning of input parameters
      • -F means a single executable file is generated
      • -W indicates that the console window is removed, which is useful in GUI interfaces. But if it is a command-line program, then remove this option!
      • -P means you customize the classpath that you need to load, and you don't normally use
      • -I represents an icon for an executable file

Python runs on an android system

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.