安装pandas及相关包的经验(对同款问题有用)

1.先直接安装 pip install pandas
失败

2.从网上说去下载后再安装,于是去了网站https://www.lfd.uci.edu/~gohlke/pythonlibs/#pandas
下载对应版本,然后在运行窗口运行如下命令,结果如下报错:
C:>pip install pandas-1.0.2-cp38-cp38-win_amd64.whl
Processing c:\pandas-1.0.2-cp38-cp38-win_amd64.whl
Collecting numpy>=1.13.3 (from pandas1.0.2)
ERROR: Could not find a version that satisfies the requirement numpy>=1.13.3 (from pandas
1.0.2) (from versions: none)
ERROR: No matching distribution found for numpy>=1.13.3 (from pandas==1.0.2)

3.网上分析说numpy的版本不够,于是去下载对应版本numpy.太慢!

4.于是直接尝试pip install numpy,结果出现反复出现警告Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError
于是百度问怎么解决,一个帖子贴了个方法:pip install selectivesearch -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
结果出来一堆英文后有个WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the ‘python -m pip install --upgrade pip’ command.

5.还是下载了numpy
然后命令行执行 pip install --user numpy-1.18.1+mkl-cp38-cp38-win_amd64.whl
安装了后还是显示警告,pip版本You are using pip version 19.2.3, however version 20.0.2 is available.

6.于是下载了pip-20.0.2-py2.py3-none-any.whl文件,并用命令进行了安装
D:>pip3 install --user pip-20.0.2-py2.py3-none-any.whl
Processing d:\pip-20.0.2-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-20.0.2

7.于是开始安装pip install --user pandas-1.0.2-cp38-cp38-win_amd64.whl
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with ‘-m pip’ instead of running pip directly.
但是有警告,解决警告的问题的方法是改命令为:python -m pip install --user pandas-1.0.2-cp38-cp38-win_amd64.whl,这样关于pip的版本警告就没有了,
但是红了一片,最后的错误提示是:

File “C:\Users\Administrator\AppData\Roaming\Python\Python38\site-packages\pip_vendor\urllib3\response.py”, line 430, in _error_catcher
raise ReadTimeoutError(self._pool, None, “Read timed out.”)
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out.

网上帖子说是超时了,于是将命令增加超时的时间限制:
用这个命令:D:>python -m pip --default-timeout=100 install --user pandas-1.0.2-cp38-cp38-win_amd64.whl
撑了好一会,最后又超时了,于是我将超时时间加大,终于成功了
D:>python -m pip --default-timeout=500 install --user pandas-1.0.2-cp38-cp38-win_amd64.whl

Processing d:\pandas-1.0.2-cp38-cp38-win_amd64.whl
Requirement already satisfied: numpy>=1.13.3 in c:\users\administrator\appdata\roaming\python\python38\site-packages (from pandas==1.0.2) (1.18.1+mkl)
Collecting python-dateutil>=2.6.1
Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting pytz>=2017.2
Downloading pytz-2019.3-py2.py3-none-any.whl (509 kB)
|████████████████████████████████| 509 kB 1.6 kB/s
Collecting six>=1.5
Downloading six-1.14.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: six, python-dateutil, pytz, pandas
Successfully installed pandas-1.0.2 python-dateutil-2.8.1 pytz-2019.3 six-1.14.0

8.安装plotly时,用的是国内源,命令:python -m pip --default-timeout=500 install --user -i https://pypi.doubanio.com/simple/ plotly

总结:从这次安装中,
1.发现解决超时在pip 和install 之间加“–default-timeout=100”
2.没有管理员权限,在install 之后包名之前加 --user
3.直接pip install 包名超时时,而且加超时时间也解决不了的慢时,可以改成国内源:
在install 和包名之间加入国内源链接https://pypi.doubanio.com/simple/
4.在pip总是提示版本警告时,在pip前加python -m 即可解决。

你可能感兴趣的:(Python网络爬虫,python,pip)