解決[WinError 87] pip自動安裝不成功問題

pip 安裝模塊報錯:[WinError 87]

C:\>pip install matplotlib
Collecting matplotlib
ERROR: Could not install packages due to an EnvironmentError: [WinError 87] The parameter is incorrect

解決辦法:手動安裝包

步驟:

1. 確認系統版本與所用Python版本:

C:\Users\>python
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

本人系統如上:Python 3.6.2 AMD64

2. 下載對應版本matplotlib

爲方便下載已將本人系統對應版本上傳資源:matplotlib
如需其他版本可到國內源下載,如清華源:清華pip源

3. 下載後安裝whl文件

PS C:\Users\Downloads> python -m pip install --user .\matplotlib-3.1.2-cp36-cp36m-win_amd64.whl
Processing c:\users\downloads\matplotlib-3.1.2-cp36-cp36m-win_amd64.whl
Requirement already satisfied: numpy>=1.11 in c:\users\appdata\local\programs\python\python36\lib\site-packages (from matplotlib==3.1.2) (1.17.4)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\appdata\local\programs\python\python36\lib\site-packages (from matplotlib==3.1.2) (2.8.0)
Collecting kiwisolver>=1.0.1
ERROR: Could not install packages due to an EnvironmentError: [WinError 87] The parameter is incorrect

在自動安裝kiwisolver時候報錯。

4. 手動安裝kiwisolver(同樣我也傳好我的對應版本)

PS C:\Users\Downloads> python -m pip install --user .\kiwisolver-1.1.0-cp36-none-win_amd64.whl
Processing c:\users\downloads\kiwisolver-1.1.0-cp36-none-win_amd64.whl
Requirement already satisfied: setuptools in c:\users\appdata\local\programs\python\python36\lib\site-packages (from kiwisolver==1.1.0) (39.0.1)
Installing collected packages: kiwisolver
Successfully installed kiwisolver-1.1.0

安裝kiwisolver成功

5.再次安裝matplotlib:

PS C:\Users\Downloads> python -m pip install --user .\matplotlib-3.1.2-cp36-cp36m-win_amd64.whl
Processing c:\users\downloads\matplotlib-3.1.2-cp36-cp36m-win_amd64.whl
Requirement already satisfied: python-dateutil>=2.1 in c:\users\appdata\local\programs\python\python36\lib\site-packages (from matplotlib==3.1.2) (2.8.0)
Collecting cycler>=0.10
  Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1
ERROR: Could not install packages due to an EnvironmentError: [WinError 87] The parameter is incorrect

自動安裝pyparsing的時候又出錯

6. 所以還要手動安裝pyparsing

PS C:\Users\Downloads> python -m pip install --user .\pyparsing-2.4.5-py2.py3-none-any.whl
Processing c:\users\downloads\pyparsing-2.4.5-py2.py3-none-any.whl
Installing collected packages: pyparsing
Successfully installed pyparsing-2.4.5

成功安裝pyparsing

7. 再安裝matplotlib成功

PS C:\Users\Downloads> python -m pip install --user .\matplotlib-3.1.2-cp36-cp36m-win_amd64.whl
Processing c:\users\downloads\matplotlib-3.1.2-cp36-cp36m-win_amd64.whl
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\appdata\roaming\python\python36\site-packages (from matplotlib==3.1.2) (1.1.0)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\appdata\local\programs\python\python36\lib\site-packages (from matplotlib==3.1.2) (2.8.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\users\appdata\roaming\python\python36\site-packages (from matplotlib==3.1.2) (2.4.5)
Collecting cycler>=0.10
  Using cached https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Requirement already satisfied: numpy>=1.11 in c:\users\appdata\local\programs\python\python36\lib\site-packages (from matplotlib==3.1.2) (1.17.4)
Requirement already satisfied: setuptools in c:\users\appdata\local\programs\python\python36\lib\site-packages (from kiwisolver>=1.0.1->matplotlib==3.1.2) (39.0.1)
Requirement already satisfied: six>=1.5 in c:\users\appdata\local\programs\python\python36\lib\site-packages (from python-dateutil>=2.1->matplotlib==3.1.2) (1.11.0)
Installing collected packages: cycler, matplotlib
Successfully installed cycler-0.10.0 matplotlib-3.1.2

9. 啓動Python命令行測試,沒有問題

>>> import matplotlib
>>>

總結:通過手動安裝完成,缺少什麼就手動安裝什麼。

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