赞
踩
工作中,服务器一般是不会开放连接外网的,那么我们在安装一些软件和环境的时候,就会没这么方便。下面主要说一下在服务器不联网的时候,怎么安装python的环境。
[root@MySQL-UAT-57 package]# yum localinstall * -y
安装pymysql包
[root@MySQL-UAT-57 pip_package]# pip3 download -d /root/package/pip_package/ pymysql
Collecting pymysql
Downloading https://files.pythonhosted.org/packages/4f/52/a115fe175028b058df353c5a3d5290b71514a83f67078a6482cff24d6137/PyMySQL-1.0.2-py3-none-any.whl (43kB)
100% |████████████████████████████████| 51kB 2.5MB/s
Saved ./PyMySQL-1.0.2-py3-none-any.whl
Successfully downloaded pymysql
[root@MySQL-UAT-57 pip_package]# ls
PyMySQL-1.0.2-py3-none-any.whl
执行以上命令,可以发现已经下载好包了,传到服务器上使用pip3进行安装。
pip3 install --no-index --find-links=/home/le/pip_package/ pymysql
安装requests包
[root@MySQL-UAT-57 pip_package]# pip3 download -d /root/package/pip_package/ requests Collecting requests Downloading https://files.pythonhosted.org/packages/29/c1/24814557f1d22c56d50280771a17307e6bf87b70727d975fd6b2ce6b014a/requests-2.25.1-py2.py3-none-any.whl (61kB) 100% |████████████████████████████████| 61kB 2.5MB/s Saved ./requests-2.25.1-py2.py3-none-any.whl Collecting certifi>=2017.4.17 (from requests) Downloading https://files.pythonhosted.org/packages/5e/a0/5f06e1e1d463903cf0c0eebeb751791119ed7a4b3737fdc9a77f1cdfb51f/certifi-2020.12.5-py2.py3-none-any.whl (147kB) 100% |████████████████████████████████| 153kB 3.3MB/s Saved ./certifi-2020.12.5-py2.py3-none-any.whl Collecting idna<3,>=2.5 (from requests) Downloading https://files.pythonhosted.org/packages/a2/38/928ddce2273eaa564f6f50de919327bf3a00f091b5baba8dfa9460f3a8a8/idna-2.10-py2.py3-none-any.whl (58kB) 100% |████████████████████████████████| 61kB 8.3MB/s Saved ./idna-2.10-py2.py3-none-any.whl Collecting urllib3<1.27,>=1.21.1 (from requests) Downloading https://files.pythonhosted.org/packages/09/c6/d3e3abe5b4f4f16cf0dfc9240ab7ce10c2baa0e268989a4e3ec19e90c84e/urllib3-1.26.4-py2.py3-none-any.whl (153kB) 100% |████████████████████████████████| 153kB 4.6MB/s Saved ./urllib3-1.26.4-py2.py3-none-any.whl Collecting chardet<5,>=3.0.2 (from requests) Downloading https://files.pythonhosted.org/packages/19/c7/fa589626997dd07bd87d9269342ccb74b1720384a4d739a1872bd84fbe68/chardet-4.0.0-py2.py3-none-any.whl (178kB) 100% |████████████████████████████████| 184kB 4.5MB/s Saved ./chardet-4.0.0-py2.py3-none-any.whl Successfully downloaded requests certifi idna urllib3 chardet [root@MySQL-UAT-57 pip_package]# [root@MySQL-UAT-57 pip_package]# ls certifi-2020.12.5-py2.py3-none-any.whl idna-2.10-py2.py3-none-any.whl requests-2.25.1-py2.py3-none-any.whl chardet-4.0.0-py2.py3-none-any.whl PyMySQL-1.0.2-py3-none-any.whl urllib3-1.26.4-py2.py3-none-any.whl
可以看到,requests涉及的包比较多,将所有包上传到服务器上之后,也是直接执行命令即可。
pip3 install --no-index --find-links=/home/le/pip_package/ requests
以上就是离线部署python环境,并安装第三方包的方法。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。