Home >Backend Development >Python Tutorial >Detailed explanation of python program packaging

Detailed explanation of python program packaging

迷茫
迷茫Original
2017-03-25 13:04:502613browse

Environment: CentOS6.5_x64
Python version: 2.6

Use pyinstaller for packaging

pyinstaller can package python programs into binary files. The packaged files are in an environment without python It can also be executed (but there must be relevant underlying libc related so files). pyinstaller supports packaging python programs into a single file. All it does is convert text into binary, which does not speed up python. On the contrary, it will affect the running speed of the packaged program.

Install pyinstaller

Install through pip:

pip install pyinstaller

Install through source code:

python setup.py install

Packaging program

Add the -F parameter. Package the program into a separate file:

pyinstaller -F test1.py

Use virtualenv packaging

virtualenv is used to create an "isolated" Python running environment for an application. Using virtualenv to manage python applications can avoid problems caused by library conflicts. Similarly, virtualenv cannot speed up Python. All it does is isolate the environment and make deployment more convenient.

Examples are as follows:

1. Install virtualenv

pip install virtualenv

2. Create a virtual environment

virtualenv -p /usr/bin/python2.6 py26env  --no-site-packages

3. Start the virtual environment

source py26env/bin/activate

4. Install the necessary python libraries

pip install …

5. After writing the code, start the program normally.

The above is the detailed content of Detailed explanation of python program packaging. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn