在Windows 10上,我已经安装了Python 3.7.3。我想通过pip install matplotlib
添加绘图模块,它似乎可以正常工作(给出成功的结果),但是当尝试使用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.
答案 0 :(得分:0)
此程序包看起来取决于我的(新)计算机上缺少的某些C ++库,因为它运行良好,并且从https://www.microsoft.com/en-in/download/details.aspx?id=48145
安装了Visual C ++ 2015后,问题已解决。感谢的帖子 DLL load failed: The specified module could not be found. in matplotlib program