似乎在安装过程中出现了问题,文件未安装或已损坏,有时我也遇到了同样的错误。
以下解决方案对我有用:
转到 cmd.exe,处理你的 venv(如果你正在使用一个),否则输入:
(venv) C:>pip uninstall matplotlib
Found existing installation: matplotlib 3.4.2
Uninstalling matplotlib-3.4.2:
Would remove:
c:\matplotlib-3.4.2-py3.9-nspkg.pth
c:\matplotlib-3.4.2.dist-info\*
c:\site-packages\matplotlib\*
c:\mpl_toolkits\axes_grid1\*
c:\mpl_toolkits\axes_grid\*
c:\mpl_toolkits\axisartist\*
c:\mpl_toolkits\mplot3d\*
c:\mpl_toolkits\tests\*
c:\pylab.py
Proceed (y/n)? y
Successfully uninstalled matplotlib-3.4.2
之后:
(venv) C:>pip install matplotlib
这应该可行。希望这有帮助。根据我的经验,使用 pip 安装软件包是最佳做法。
当我运行 pypy3 -m pip install matplotlib 时,发生了一些麻烦
错误:命令出错,退出状态为 1:
命令:'C:\Users\Bitao_Dai\pypy3.7-v7.3.4-win64\pypy3.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\BITAO_~1\AppData\Local\Temp\pip-install-xzb8mrhq\matplotlib_c20db475c8ba4ee6bec5b5683911048a\setup.py'"'"'; 文件='"'"'C:\Users\BITAO_~1\AppData\Local\Temp\pip-install-xzb8mrhq\matplotlib_c20db475c8ba4ee6bec5b5683911048a\setup.py'"'"';f = getattr( tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"' "'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n' "'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users \BITAO_~1\AppData\Local\Temp\pip-record-narl5jt6\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Bitao_Dai\pypy3. 7-v7.3.4-win64\include\matplotlib'
cwd: C:\Users\BITAO_~1\AppData\Local\Temp\pip-install-xzb8mrhq\matplotlib_c20db475c8ba4ee6bec5b5683911048a
完整输出(552 行):
Edit setup.cfg to change the build options; suppress output with --quiet.
错误:需要 Microsoft Visual C++ 14.0。使用“Visual Studio 构建工具”获取它:https://visualstudio.microsoft.com/downloads/
--------------------------------------
错误:命令出错,退出状态为 1:'C:\Users\Bitao_Dai\pypy3.7-v7.3.4-win64\pypy3.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\BITAO_~1\AppData\Local\Temp\pip-install-xzb8mrhq\matplotlib_c20db475c8ba4ee6bec5b5683911048a\setup.py'"'"'; 文件='"'"'C:\Users\BITAO_~1\AppData\Local\Temp\pip-install-xzb8mrhq\matplotlib_c20db475c8ba4ee6bec5b5683911048a\setup.py'"'"';f = getattr( tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"' "'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n' "'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users \BITAO_~1\AppData\Local\Temp\pip-record-narl5jt6\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Bitao_Dai\pypy3. 7-v7.3.4-win64\include\matplotlib' 检查日志以获取完整的命令输出。