外网python2.7 虚拟环境中安装了 flask 模块,期望在内网使用,如何迁移外网的虚拟环境到内网呢?
1 进入外网python虚拟环境
[root@localhost 20200422]# source python27_virtual_env/bin/activate
(python27_virtual_env) [root@localhost 20200422]#
2 导入虚拟环境中已安装包的信息到requirements.txt 文件中
(python27_virtual_env) [root@localhost 20200422]# pip freeze --all >requirements.txt
3 创建一个临时目录,将安装包下载到该目录下
(python27_virtual_env) [root@localhost 20200422]# mkdir whls
(python27_virtual_env) [root@localhost 20200422]# cd whls
(python27_virtual_env) [root@localhost whls]# pip download -r ../requirements.txt -d .
(python27_virtual_env) [root@localhost whls]# ll
total 4368
-rw-r--r--. 1 root root 6790 May 14 12:16 atomicwrites-1.4.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root 39472 May 14 12:16 attrs-19.3.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root 5670 May 14 12:16 backports.functools_lru_cache-1.6.1-py2.py3-none-any.whl
-rw-r--r--. 1 root root 109519 May 14 12:16 beautifulsoup4-4.9.0-py2-none-any.whl
-rw-r--r--. 1 root root 157007 May 14 12:16 certifi-2020.4.5.1-py2.py3-none-any.whl
-rw-r--r--. 1 root root 133356 May 14 12:16 chardet-3.0.4-py2.py3-none-any.whl
-rw-r--r--. 1 root root 82780 May 14 12:16 click-7.1.2-py2.py3-none-any.whl
-rw-r--r--. 1 root root 22828 May 14 12:16 configparser-4.0.2-py2.py3-none-any.whl
-rw-r--r--. 1 root root 9770 May 14 12:16 contextlib2-0.6.0.post1-py2.py3-none-any.whl
-rw-r--r--. 1 root root 94570 May 14 12:16 Flask-1.1.2-py2.py3-none-any.whl
-rw-r--r--. 1 root root 17697 May 14 12:16 funcsigs-1.0.2-py2.py3-none-any.whl
-rw-r--r--. 1 root root 58388 May 14 12:16 idna-2.9-py2.py3-none-any.whl
-rw-r--r--. 1 root root 30763 May 14 12:16 importlib_metadata-1.6.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root 16743 May 14 12:16 itsdangerous-1.1.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root 125774 May 14 12:16 Jinja2-2.11.2-py2.py3-none-any.whl
-rw-r--r--. 1 root root 24348 May 14 12:16 MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_x86_64.whl
-rw-r--r--. 1 root root 52303 May 14 12:16 more_itertools-5.0.0-py2-none-any.whl
-rw-r--r--. 1 root root 37090 May 14 12:16 packaging-20.3-py2.py3-none-any.whl
-rw-r--r--. 1 root root 18252 May 14 12:16 pathlib2-2.3.5-py2.py3-none-any.whl
-rw-r--r--. 1 root root 1489786 May 14 12:16 pip-20.1-py2.py3-none-any.whl
-rw-r--r--. 1 root root 18077 May 14 12:16 pluggy-0.13.1-py2.py3-none-any.whl
-rw-r--r--. 1 root root 83824 May 14 12:16 py-1.8.1-py2.py3-none-any.whl
-rw-r--r--. 1 root root 67842 May 14 12:16 pyparsing-2.4.7-py2.py3-none-any.whl
-rw-r--r--. 1 root root 231581 May 14 12:16 pytest-4.6.10-py2.py3-none-any.whl
-rw-r--r--. 1 root root 269377 May 14 12:16 PyYAML-5.3.1.tar.gz
-rw-r--r--. 1 root root 58406 May 14 12:16 requests-2.23.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root 33311 May 14 12:16 scandir-1.10.0.tar.gz
-rw-r--r--. 1 root root 583351 May 14 12:16 setuptools-44.1.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root 10938 May 14 12:16 six-1.14.0-py2.py3-none-any.whl
-rw-r--r--. 1 root root 33516 May 14 12:16 soupsieve-1.9.5-py2.py3-none-any.whl
-rw-r--r--. 1 root root 126746 May 14 12:16 urllib3-1.25.9-py2.py3-none-any.whl
-rw-r--r--. 1 root root 19410 May 14 12:16 wcwidth-0.1.9-py2.py3-none-any.whl
-rw-r--r--. 1 root root 298631 May 14 12:16 Werkzeug-1.0.1-py2.py3-none-any.whl
-rw-r--r--. 1 root root 26502 May 14 12:16 wheel-0.34.2-py2.py3-none-any.whl
-rw-r--r--. 1 root root 4821 May 14 12:16 zipp-1.2.0-py2.py3-none-any.whl
4 将创建好的虚拟环境打包,拷贝到新的环境中
5 解压,激活该虚拟环境
6 将whls 目录拷贝解压到新环境的目录下
7 执行安装命令安装
pip install --no-index --find-links=your_offline_packages -r requirements.txt
8 详细迁移方法参考
https://www.cnblogs.com/yhleng/p/9921641.html
https://zhuanlan.zhihu.com/p/134306869