簡體   English   中英

在Windows上使用pip成功安裝后,Python導入matplotlib失敗

[英]Python import matplotlib fails after successful install using pip on Windows

在Windows 10上,我安裝了Python 3.7.3。 我想通過pip install matplotlib添加plot模塊,它似乎工作正常(給出成功結果),但是當嘗試導入帶有import matplotlib.pyplot as plt的庫import matplotlib.pyplot as plt它無法說找不到指定的模塊。

我試過py -m pip install...還有python -m pip install...似乎沒有解決我的問題。

以下是我嘗試安裝模塊的方法:

c:\Users\Michael\Documents>pip install matplotlib
Collecting matplotlib
  Using cached https://files.pythonhosted.org/packages/76/e2/f87bf36a2a460857ec9c28535e00102eb6908a727e427adc6427c5dc5453/matplotlib-3.1.0-cp37-cp37m-win32.whl
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
  Using cached https://files.pythonhosted.org/packages/dd/d9/3ec19e966301a6e25769976999bd7bbe552016f0d32b577dc9d63d2e0c49/pyparsing-2.4.0-py2.py3-none-any.whl
Collecting python-dateutil>=2.1 (from matplotlib)
  Using cached https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl
Collecting kiwisolver>=1.0.1 (from matplotlib)
  Using cached https://files.pythonhosted.org/packages/20/6a/e5fff2ed776ab0cd11d7c1d5d3e5e549952464a6f1b9084b7ecbd8341352/kiwisolver-1.1.0-cp37-none-win32.whl
Requirement already satisfied: numpy>=1.11 in c:\program files (x86)\python37-32\lib\site-packages (from matplotlib) (1.16.3)
Collecting cycler>=0.10 (from matplotlib)
  Using cached https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting six>=1.5 (from python-dateutil>=2.1->matplotlib)
  Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in c:\program files (x86)\python37-32\lib\site-packages (from kiwisolver>=1.0.1->matplotlib) (40.8.0)
Installing collected packages: pyparsing, six, python-dateutil, kiwisolver, cycler, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.1.0 pyparsing-2.4.0 python-dateutil-2.8.0 six-1.12.0
You are using pip version 19.0.3, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

這是我的計算機上包含python的路徑:

c:\Users\Michael\Documents>path
PATH=C:\Program Files (x86)\Python37-32\Scripts\;C:\Program Files (x86)\Python37-32\;....

這是我得到的錯誤(從空閑或啟動python后的CMD):

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<pyshell#61>", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\matplotlib\__init__.py", line 200, in <module>
    _check_versions()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\matplotlib\__init__.py", line 194, in _check_versions
    module = importlib.import_module(modname)
  File "C:\Program Files (x86)\Python37-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: The specified module could not be found.

看起來這個包取決於我在(新)計算機上缺少的一些C ++庫,因為它在我從https://www.microsoft.com/en-in/安裝visual C ++ 2015之后工作正常並且問題已經解決下載/ details.aspx?ID = 48145

感謝DLL加載失敗的帖子:找不到指定的模塊。 在matplotlib程序中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM