在搭建python基本环境后,安装pandas出现无法安装的情况,如下报错
pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pandas
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9f/12/0b6bdd627b99cb10816956c1047b0733ef33b61a84e3420faf4d3202df06/pandas-2.0.0.tar.gz (5.3MB)
100% |████████████████████████████████| 5.3MB 228kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
import numpy
ModuleNotFoundError: No module named 'numpy'
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-kn6n2nu5/pandas/
这时如果根据提示安装缺少的包,可能会很慢,而且最后也无法安装所有需要的包,不是提示网络连接超市,就是安装时报告一些莫名其妙的错误。其实解决方法很简单,只要升级pip版本就可以直接安装pandas相应的所有包了,具体方法如下
pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pip
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/07/51/2c0959c5adf988c44d9e1e0d940f5b074516ecc87e96b1af25f59de9ba38/pip-23.0.1-py3-none-any.whl (2.1MB)
100% |████████████████████████████████| 2.1MB 551kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Successfully uninstalled pip-9.0.1
Successfully installed pip-23.0.1
(python38_env) [root@176-168-0-95 ~]# pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pandas
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/23/c0/4b71d4a9fbfe2fbe3e379bebc22bc935e4d09b7802899a5ac1b90bf090bb/pandas-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.3/12.3 MB 4.2 MB/s eta 0:00:00
Collecting tzdata>=2022.1
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d5/fb/a79efcab32b8a1f1ddca7f35109a50e4a80d42ac1c9187ab46522b2407d7/tzdata-2023.3-py2.py3-none-any.whl (341 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 341.8/341.8 kB 4.4 MB/s eta 0:00:00
Collecting python-dateutil>=2.8.2
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 4.4 MB/s eta 0:00:00
Collecting numpy>=1.20.3
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9c/ee/77768cade9607687fadbcc1dcbb82dba0554154b3aa641f9c17233ffabe8/numpy-1.24.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.3/17.3 MB 4.2 MB/s eta 0:00:00
Requirement already satisfied: pytz>=2020.1 in /data1/python/virtualenv/python38_env/lib/python3.8/site-packages (from pandas) (2022.7.1)
Collecting six>=1.5
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: tzdata, six, numpy, python-dateutil, pandas
Successfully installed numpy-1.24.2 pandas-2.0.0 python-dateutil-2.8.2 six-1.16.0 tzdata-2023.3