linux服务器本地安装python3需要的pandas库

背景

linux服务器无法访问外网,不可以直接安装python3需要的依赖库,此时就需要将库下载下来,然后上传到linux服务器上离线安装

安装pandas库

找可以连外网的linux在线安装,然后把库下载下来

[root@localhost ~]# pip3 install pandas
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting pandas
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/c3/e2/00cacecafbab071c787019f00ad84ca3185952f6bb9bca9550ed83870d4d/pandas-1.1.5-cp36-cp36m-manylinux1_x86_64.whl (9.5MB)
    100% |████████████████████████████████| 9.5MB 85.1MB/s
Collecting numpy>=1.15.4 (from pandas)
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl (13.4MB)
    100% |████████████████████████████████| 13.4MB 84.1MB/s
Collecting python-dateutil>=2.7.3 (from pandas)
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl (247kB)
    100% |████████████████████████████████| 256kB 85.4MB/s
Collecting pytz>=2017.2 (from pandas)
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/7f/99/ad6bd37e748257dd70d6f85d916cafe79c0b0f5e2e95b11f7fbc82bf3110/pytz-2023.3-py2.py3-none-any.whl (502kB)
    100% |████████████████████████████████| 512kB 89.5MB/s
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/site-packages (from python-dateutil>=2.7.3->pandas)
Installing collected packages: numpy, python-dateutil, pytz, pandas
Successfully installed numpy-1.19.5 pandas-1.1.5 python-dateutil-2.8.2 pytz-2023.3

找到url的包,手动get下来

[root@localhost panda]# wget 'http://mirrors.cloud.aliyuncs.com/pypi/packages/7f/99/ad6bd37e748257dd70d6f85d916cafe79c0b0f5e2e95b11f7fbc82bf3110/pytz-2023.3-py2.py3-none-any.whl'
--2023-06-26 15:09:43--  http://mirrors.cloud.aliyuncs.com/pypi/packages/7f/99/ad6bd37e748257dd70d6f85d916cafe79c0b0f5e2e95b11f7fbc82bf3110/pytz-2023.3-py2.py3-none-any.whl
Resolving mirrors.cloud.aliyuncs.com (mirrors.cloud.aliyuncs.com)... 100.100.2.148
Connecting to mirrors.cloud.aliyuncs.com (mirrors.cloud.aliyuncs.com)|100.100.2.148|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 502345 (491K) [application/octet-stream]
Saving to: ‘pytz-2023.3-py2.py3-none-any.whl’

100%[=======================================================================>] 502,345     --.-K/s   in 0.06s

2023-06-26 15:09:43 (7.63 MB/s) - ‘pytz-2023.3-py2.py3-none-any.whl’ saved [502345/502345]

[root@localhost panda]# wget 'http://mirrors.cloud.aliyuncs.com/pypi/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl'
--2023-06-26 15:09:58--  http://mirrors.cloud.aliyuncs.com/pypi/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl
Resolving mirrors.cloud.aliyuncs.com (mirrors.cloud.aliyuncs.com)... 100.100.2.148
Connecting to mirrors.cloud.aliyuncs.com (mirrors.cloud.aliyuncs.com)|100.100.2.148|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 247702 (242K) [application/octet-stream]
Saving to: ‘python_dateutil-2.8.2-py2.py3-none-any.whl’

100%[=======================================================================>] 247,702     78.0KB/s   in 3.1s

2023-06-26 15:10:01 (78.0 KB/s) - ‘python_dateutil-2.8.2-py2.py3-none-any.whl’ saved [247702/247702]

[root@localhost panda]# wget 'http://mirrors.cloud.aliyuncs.com/pypi/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl'
--2023-06-26 15:10:15--  http://mirrors.cloud.aliyuncs.com/pypi/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl
Resolving mirrors.cloud.aliyuncs.com (mirrors.cloud.aliyuncs.com)... 100.100.2.148
Connecting to mirrors.cloud.aliyuncs.com (mirrors.cloud.aliyuncs.com)|100.100.2.148|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13391355 (13M) [application/octet-stream]
Saving to: ‘numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl’

100%[=======================================================================>] 13,391,355  62.6MB/s   in 0.2s

2023-06-26 15:10:15 (62.6 MB/s) - ‘numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl’ saved [13391355/13391355]

[root@localhost panda]# wget 'http://mirrors.cloud.aliyuncs.com/pypi/packages/c3/e2/00cacecafbab071c787019f00ad84ca3185952f6bb9bca9550ed83870d4d/pandas-1.1.5-cp36-cp36m-manylinux1_x86_64.whl'
--2023-06-26 15:10:27--  http://mirrors.cloud.aliyuncs.com/pypi/packages/c3/e2/00cacecafbab071c787019f00ad84ca3185952f6bb9bca9550ed83870d4d/pandas-1.1.5-cp36-cp36m-manylinux1_x86_64.whl
Resolving mirrors.cloud.aliyuncs.com (mirrors.cloud.aliyuncs.com)... 100.100.2.148
Connecting to mirrors.cloud.aliyuncs.com (mirrors.cloud.aliyuncs.com)|100.100.2.148|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9513189 (9.1M) [application/octet-stream]
Saving to: ‘pandas-1.1.5-cp36-cp36m-manylinux1_x86_64.whl’

100%[=======================================================================>] 9,513,189   --.-K/s   in 0.1s

2023-06-26 15:10:28 (63.8 MB/s) - ‘pandas-1.1.5-cp36-cp36m-manylinux1_x86_64.whl’ saved [9513189/9513189]

备注:经过测试发现还少一个six,下面是连接,也需要下载

https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl

检查pandas的库文件是否有缺漏

[root@localhost panda]#
[root@localhost panda]# ls
numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl  python_dateutil-2.8.2-py2.py3-none-any.whl
pandas-1.1.5-cp36-cp36m-manylinux1_x86_64.whl  pytz-2023.3-py2.py3-none-any.whl

四个包在同一个路径下,统一放到另一台服务器上面

手动本地安装

[root@localhost panda]# pip3 install pandas-1.1.5-cp36-cp36m-manylinux1_x86_64.whl
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Processing ./pandas-1.1.5-cp36-cp36m-manylinux1_x86_64.whl
Collecting numpy>=1.15.4 (from pandas==1.1.5)
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl (13.4MB)
    100% |████████████████████████████████| 13.4MB 58.9MB/s
Collecting python-dateutil>=2.7.3 (from pandas==1.1.5)
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl (247kB)
    100% |████████████████████████████████| 256kB 87.4MB/s
Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/site-packages (from pandas==1.1.5)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/site-packages (from python-dateutil>=2.7.3->pandas==1.1.5)
Installing collected packages: numpy, python-dateutil, pandas
Successfully installed numpy-1.19.5 pandas-1.1.5 python-dateutil-2.8.2

验证

[root@localhost panda]# python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pds
>>>
>>>
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> exit()
[root@localhost panda]#
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值