虚拟环境的搭建
优点
1 2 3
|
1、使不同应用开发环境相互独立 2、环境升级不影响其他应用,也不会影响全局的python环境 3、防止出现包管理混乱及包版本冲突
|
windows
安装
1 2 3
|
# 建议使用pip3安装到python3环境下 pip3 install virtualenv pip3 install virtualenvwrapper-win
|
配置虚拟环境管理器工作目录
MacOS、Linux
安装
1 2 3
|
# 建议使用pip3安装到python3环境下 pip3 install -i https://pypi.douban.com/simple virtualenv pip3 install -i https://pypi.douban.com/simple virtualenvwrapper
|
工作文件
1 2 3 4 5 6
|
# 先找到virtualenvwrapper的工作文件 virtualenvwrapper.sh,该文件可以刷新自定义配置,但需要找到它
|
配置
1 2 3 4 5 6 7
|
# 在 ~/.bash_profile 完成配置,virtualenvwrapper的默认默认存放虚拟环境路径是 ~/.virtualenvs
|
使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
# 在终端工作的命令
|
pycharm使用
新建项目

添加环境

使用环境

配置虚拟环境


初始化环境配置
pip3 install -r requirements.txt