1.查看python安装的第三方库
pip list
下面是在线安装
2.将python第三方库导入*.txt文件
在你想要保存的路径下cmd操作方便
pip freeze > filename.txt
filename.txt (filename名称自己可以命名)
也有可能是下面这样。
pip freeze输出的是本地环境中所有三方包信息,但是会比pip list少几个包,因为pip,wheel,setuptools等包,是自带的而无法install的
3.在新的服务器通过映入*.txt安装第三方库
pip install -r requirement.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
-i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com 这个是镜像源
下面是离线安装
4.离线安装到新环境
pip download -r requirements.txt -d python_list
注意在这之前得修改requirements.txt文件内容
原始
修该为文件的全名(离线是这样,在线安装直接利用requriement.txt安装即可)
开始在新环境离线安装第三方库
pip install --no-index --find-links=python_list -r requirements.txt
安装requirements.txt里的依赖包。
注意