I'm trying to use matplotlib in python, specifically, in PyCharm IDE. I have Windows 10 and Python 3.8 and I checked that everything was up to date (like pip).
I installed matplotlib via pip with the command "pip install matplotlib", till then everything was okay because I didn't get any error in the cmd and it was successful.
The problem appears when I try to install the package into the project in PyCharm, and an error appears. I haven't found this error on any website and I've tried lots of things, like reinstalling python and PyCharm, installing the library with conda environment, also trying to install updated FreeType but I don't know how to do it...
Also, I noticed that when I import matplotlib in python.exe any error appears, so I thought the error might be in PyCharm, but this is just a speculation. Here's the error:
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."
I don't know how to install an updated FreeType version or setting the MPLLOCALFREETYPE to 1 as the error suggested.
If I can provide more information or more code please let me know, I don't know if I asked "correctly".
Update:
I've tried to write the command also in the terminal of venv and I think I get the same error, but with more detail, it mentions something regarding Microsoft visual studio. Here the error:
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\```
If an error occurs while installing a package in PyCharm, it may be due to a new version of the “pip” package on your computer. You have to update it before a package will install. To update “pip”: Go to “Project Interpreter.” Click on it.
Troubleshooting: Try installing/importing a package from the system terminal (outside of PyCharm) using the same interpreter/environment. In case you are using a virtualenv/conda environment as your Project Interpreter in PyCharm, it is enough to activate that environment in the system terminal and then do the test.
The most frequent source of this error is that you haven't installed matplotlib explicitly with pip install matplotlib . Alternatively, you may have different Python versions on your computer, and matplotlib is not installed for the particular version you're using.
Try:
sudo apt-get install libfreetype6-dev
sudo apt-get install pkg-config
sudo apt-get install libpng12-dev
sudo apt-get install pkg-config
Ref: 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. Works with latest version of PyCharm 2019.3.4 Professional and Python 3.8 on Windows 10.
I solved the problem just downloading another version of matplotlib.
python -m pip install -U matplotlib==3.2.0rc1```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With