Detailed explanation of python program packaging

迷茫
Release: 2017-03-25 13:04:50
Original
2571 people have browsed it

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
Copy after login

Install through source code:

python setup.py install
Copy after login

Packaging program

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

pyinstaller -F test1.py
Copy after login

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
Copy after login

2. Create a virtual environment

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

3. Start the virtual environment

source py26env/bin/activate
Copy after login

4. Install the necessary python libraries

pip install …
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template