安裝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 即可解決。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章