python如何创建虚拟环境

86 阅读1分钟

1、创建虚拟目录 python -m venv +虚拟目录所在路径

2、进入虚拟目录

(1)先cd到虚拟目录的scrips中

(2)再输入activate

3、安装pip install pipreqs包,用此包生成程序所用包的txt目录

4、执行pip install -r requirements.txt命令,安装程序所用的包

5、打包命令: pyinstaller -F -w py文件名 -c是带控制台的


服务器中

1.在python项目管理器中添加项目

2.生成虚拟环境必要文件

cd /www/wwwroot/python

python3 -m venv +虚拟环境名称

3.终端安装必要库 cd /www/wwwroot/python

source 虚拟环境名称/bin/activate

pip install 库

4.定时任务设置

cd /www/wwwroot/python

source 虚拟环境名称/bin/activate

python winxi.py


清华源 pip install -i pypi.tuna.tsinghua.edu.cn/simple some-package