【发布时间】:2020-07-01 01:31:26
【问题描述】:
我正在尝试在 python 中使用 matplotlib,特别是在 PyCharm IDE 中。我有 Windows 10 和 Python 3.8,我检查了一切都是最新的(比如 pip)。
我通过 pip 使用命令“pip install matplotlib”安装了 matplotlib,直到那时一切都很好,因为我在 cmd 中没有收到任何错误并且它是成功的。
当我尝试在 PyCharm 中将包安装到项目中时出现问题,并出现错误。我在任何网站上都没有发现这个错误,我已经尝试了很多东西,比如重新安装 python 和 PyCharm,安装带有 conda 环境的库,还尝试安装更新的 FreeType,但我不知道该怎么做。 .
另外,我注意到当我在 python.exe 中导入 matplotlib 时会出现任何错误,所以我认为错误可能在 PyCharm 中,但这只是一个猜测。 这是错误:
src/checkdep_freetype2.c(5): fatal error C1189: #error: "FreeType version 2.3 or higher is required. You may set the MPLLOCALFREETYPE environment variable to 1 to let Matplotlib download it."
我不知道如何安装更新的 FreeType 版本或按照错误提示将 MPLLOCALFREETYPE 设置为 1。
如果我可以提供更多信息或更多代码,请告诉我,我不知道我问的是否“正确”。
更新:
我也尝试在 venv 的终端中编写命令,但我想我得到了同样的错误,但更详细地说,它提到了一些关于 Microsoft Visual Studio 的内容。这里的错误:
IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18
362.0\cppwinrt" /Tcsrc/checkdep_freetype2.c /Fobuild\temp.win32-3.8\Release\src/checkdep_freetype2.obj
checkdep_freetype2.c
src/checkdep_freetype2.c(5): fatal error C1189: #error: "FreeType version 2.3 or higher is required. You may set the MPLLOCALFREETYPE environment variable to 1 to let Matplotlib download
it."
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
----------------------------------------
Command "C:\Users\Samuel\PycharmProjects\untitled\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\temp\\pip-install-pzdo9qwp\\matplotlib\\setup.py';f=getattr(tokenize,
'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\temp\pip-record-059s14h2\install-record.txt --single-version-e
xternally-managed --compile --install-headers C:\Users\Samuel\PycharmProjects\untitled\venv\include\site\python3.8\matplotlib" failed with error code 1 in C:\temp\pip-install-pzdo9qwp\matplotl
ib\```
【问题讨论】:
-
你在使用环境吗?
-
我用的是python虚拟环境,安装python时自带的(virtualenv)
标签: python python-3.x matplotlib pip pycharm