使用virtualenv创建python项目环境

virtualenv 能够创建干净的python库环境.避免污染python项目环境

yum install -y virtualenv
--no-site-packages参数是指不从全局的Python中携带任何第三方库
[vvv@node1 test-workspace]$ virtualenv --no-site-packages test_env
Using base prefix '/usr'
New python executable in /home/vvv/test-workspace/test_env/bin/python3.6
Also creating executable in /home/vvv/test-workspace/test_env/bin/python
Installing setuptools, pip, wheel...done.

[vvv@node1 test-workspace]$ cd test_env/
[vvv@node1 test_env]$ source bin/activate
(test_env) [vvv@node1 test_env]$ pip freeze

# 指定python版本
    virtualenv --no-site-packages test_env --python=python3.6

# 安装需要的库
# pip install six
# pip freeze > requirements.txt  # 导出已安装的库
# pip install -r requirements.txt # 导入需要的库
(test_env) [vvv@node1 test_env]$ deactivate

全局级别安装库

sudo pip3  install pyinstaller

用户级安装库

pip3  install pyinstaller --user

支持sock5 proxy

 pip install pysocks

使用代理

pip install -r requirements.txt --proxy='socks5://192.168.8.73:61080'
Published
Categorized as py

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.