我试图在python中使用matplotlib,特别是在PyIDE中。我有Windows10和Python3.8,我检查了所有东西是否都是最新的(比如pip)
我使用命令“pip install matplotlib”通过pip安装了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\```
我只需下载另一个版本的matplotlib就解决了这个问题
尝试:
参考:https://hackaday.io/project/53896-weedinator-2019/log/153140-jupyter-notebook-3-days-to-get-a-photo-of-a-cat
Try updating your setuptools and pip to latest versions by clicking on the arrow up. Because I also updated pip through command prompt and it was not working. Has to do something with the PATH it is looking in. 适用于Windows 10上最新版本的PyCharm 2019.3.4 Professional和Python 3.8。
相关问题 更多 >
编程相关推荐