- 作用:记录所有项目所依赖的第三方模块,方便迁移到不同的环境中,防止缺少模块,或因为所依赖的第三方模块不同而引起的一系列问题。
- 生成该文件的命令:
pip freeze > requirements.txt
- 安装文件中所包含的所有模块的命令:
pip install -r requirements.txt
更换环境后,只需复制此文件到新的环境中,再执行命令即可 - 使用镜像:
安装单个包:
~使用阿里云镜像:
pip install scrapy -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
安装requirements.txt:pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
- 国内常用的pip源如下:
阿里云:http://mirrors.aliyun.com/pypi/simple/
豆瓣:http://pypi.douban.com/simple/
清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学:http://pypi.mirrors.ustc.edu.cn/simple/
pycharm中的requirements.txt文件—如何生成及导入
最新推荐文章于 2024-07-05 16:53:58 发布