Python program packaging and python Packaging

Source: Internet
Author: User
Tags virtual environment virtualenv

Python program packaging and python Packaging

Environment: CentOS6.5 _ x64
Python: 2.6

Use pyinstaller to package

Pyinstaller can package a python program into a binary file. The packaged file can also be executed in an environment without python (however, the underlying libc-related so file must exist ). Pyinstaller supports packaging a python program into a single file. All it does is convert the text into binary, which does not speed up python. On the contrary, it also affects the running speed of the packaged program.

Install pyinstaller

Official Website: http://www.pyinstaller.org/

Install using pip:

pip install pyinstaller

Install using source code:

python setup.py install   
Package

With the-F parameter, You can package the program into a separate file:

pyinstaller -F test1.py 
Use virtualenv to package

Virtualenv is used to create an "isolated" Python runtime environment for an application. Using virtualenv to manage python applications can avoid problems caused by library conflicts. Similarly, virtualenv cannot speed up python. It only isolates the environment and facilitates deployment.

Example:

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 necessary python libraries

pip install …

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

Okay, that's all. I hope it will help you.

Github address:

Bytes

Please add

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.