Установка matplotlib python windows

Hello.

I’m facing difficulty to use PyPlot on my windows 10 machine.
The versions I’m using are: Julia v1.3.0; Conda v1.3.0; PyCall v1.91.2; PyPlot v2.8.2. I already installed the latest matlibplot via Conda.update(), and it’s v3.1.1 now. Also, the python executable used by PyCall seems to be correctly specified:

julia> using PyCall
julia> PyCall.python
"C:\\Users\\xxx\\.julia\\conda\\3\\python.exe"

Then, I got the following errors. Essentially, PyPlot keeps trying to install matplotlib even though it was already installed. In fact, the warnings below say «All requested packages already installed.» Yet, each time when I try to use PyPlot, this happens and I cannot use it on windows. It works under macOS though. I would greatly appreciate it if someone could tell me what to do.
Thanks!

julia> using PyPlot
[ Info: Installing matplotlib via the Conda matplotlib package...
[ Info: Running `conda install -y matplotlib` in root environment
Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

ERROR: InitError: PyCall.PyError("PyImport_ImportModule\n\nThe Python package matplotlib could not be found by pyimport. Usually this means\nthat you did not install matplotlib in the Python version being used by PyCall.\n\nPyCall is currently configured to use the Julia-specific Python distribution\ninstalled by the Conda.jl package.  To install the matplotlib module, you can\nuse `pyimport_conda(\"matplotlib\", PKG)`, where PKG is the Anaconda\npackage the contains the module matplotlib, or alternatively you can use the\nConda package directly (via `using Conda` followed 
by `Conda.add` etcetera).\n\nAlternatively, if you want to use a different Python distribution on your\nsystem, such as a system-wide Python (as 
opposed to the Julia-specific Python),\nyou can re-configure PyCall with that Python.   As explained in the PyCall\ndocumentation, set ENV[\"PYTHON\"] to the path/name of the python executable\nyou want to use, run Pkg.build(\"PyCall\"), and re-launch Julia.\n\n", PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x000000006b8a4290), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x0000000030ba39e8), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x0000000030bae888))
Stacktrace:
 [1] pyimport(::String) at C:\Users\xxx\.julia\packages\PyCall\ttONZ\src\PyCall.jl:544
 [2] pyimport_conda(::String, ::String, ::String) at C:\Users\xxx\.julia\packages\PyCall\ttONZ\src\PyCall.jl:708
 [3] pyimport_conda at C:\Users\xxx\.julia\packages\PyCall\ttONZ\src\PyCall.jl:701 [inlined]
 [4] __init__() at C:\Users\xxx\.julia\packages\PyPlot\4wzW1\src\init.jl:179
 [5] _include_from_serialized(::String, ::Array{Any,1}) at .\loading.jl:692
 [6] _require_search_from_serialized(::Base.PkgId, ::String) at .\loading.jl:776
 [7] _require(::Base.PkgId) at .\loading.jl:1001
 [8] require(::Base.PkgId) at .\loading.jl:922
 [9] require(::Module, ::Symbol) at .\loading.jl:917
during initialization of module PyPlot

Posted by Guy Lorshbaugh

I’m getting an error installing matplotlib 2.2.2 through PowerShell. I’m using Windows 10, Python version 3.8.3. If there’s any help to be had I’d love it, thanks!!

This is the very long error report that PowerShell returned:

PS C:\users\guylo\desktop> pipenv install matplotlib==2.2.2
Creating a virtualenv for this project…
Pipfile: C:\users\guylo\desktop\Pipfile
Using C:/Users/guylo/AppData/Local/Programs/Python/Python38-32/python.exe (3.8.3) to create virtualenv…
[  ==] Creating virtual environment...created virtual environment CPython3.8.3.final.0-32 in 386ms
  creator CPython3Windows(dest=C:\Users\guylo\.virtualenvs\desktop-3fcGtUnN, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\guylo\AppData\Local\pypa\virtualenv)
    added seed packages: pip==20.2.2, setuptools==49.6.0, wheel==0.35.1
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

Successfully created virtual environment!
Virtualenv location: C:\Users\guylo\.virtualenvs\desktop-3fcGtUnN
Creating a Pipfile for this project…
Installing matplotlib==2.2.2…
Error:  An error occurred while installing matplotlib==2.2.2!
Error text: Collecting matplotlib==2.2.2
  Using cached matplotlib-2.2.2.tar.gz (37.3 MB)

    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\guylo\.virtualenvs\desktop-3fcGtUnN\Scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\guylo\\AppData\\Local\\Temp\\pip-install-qoyyit2b\\matplotlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\guylo\\AppData\\Local\\Temp\\pip-install-qoyyit2b\\matplotlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\guylo\AppData\Local\Temp\pip-pip-egg-info-acq95m_9'
         cwd: C:\Users\guylo\AppData\Local\Temp\pip-install-qoyyit2b\matplotlib\
    Complete output (61 lines):
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [2.2.2]
                    python: yes [3.8.3 (tags/v3.8.3:6f8c832, May 13 2020,
                            22:20:19) [MSC v.1925 32 bit (Intel)]]
                  platform: yes [win32]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [not found. pip may install it below.]
          install_requires: yes [handled by setuptools]
                    libagg: yes [pkg-config information for 'libagg' could not
                            be found. Using local copy.]
                  freetype: no  [The C/C++ header for freetype
                            (freetype2\ft2build.h) could not be found.  You may
                            need to install the development package.]
                       png: no  [The C/C++ header for png (png.h) could not be
                            found.  You may need to install the development
                            package.]
                     qhull: yes [pkg-config information for 'libqhull' could not
                            be found. Using local copy.]

    OPTIONAL SUBPACKAGES
               sample_data: yes [installing]
                  toolkits: yes [installing]
                     tests: no  [skipping due to configuration]
            toolkits_tests: no  [skipping due to configuration]

    OPTIONAL BACKEND EXTENSIONS
                    macosx: no  [Mac OS-X only]
                    qt5agg: no  [PySide2 not found; PyQt5 not found]
                    qt4agg: no  [PySide not found; PyQt4 not found]
                   gtk3agg: no  [Requires pygobject to be installed.]
                 gtk3cairo: no  [Requires cairocffi or pycairo to be installed.]
                    gtkagg: no  [Requires pygtk]
                     tkagg: yes [installing; run-time loading from Python Tcl /
                            Tk]
                     wxagg: no  [requires wxPython]
                       gtk: no  [Requires pygtk]
                       agg: yes [installing]
                     cairo: no  [cairocffi or pycairo not found]
                 windowing: yes [installing]

    OPTIONAL LATEX DEPENDENCIES
                    dvipng: no
               ghostscript: no
                     latex: no
                   pdftops: no

    OPTIONAL PACKAGE DATA
                      dlls: no  [skipping due to configuration]

    ============================================================================
                            * The following required packages can not be built:
                            * freetype, png
                            * Please check http://gnuwin32.sourceforge.net/packa
                            * ges/freetype.htm for instructions to install
                            * freetype
                            * Please check http://gnuwin32.sourceforge.net/packa
                            * ges/libpng.htm for instructions to install png
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

This is likely caused by a bug in matplotlib. Report this to its maintainers.

2 Answers

MOD

Sorry, did not see this question until this morning— I was able to reproduce your problem!!

The short answer is don’t install this specific version of matplotlib with the version of Python you have, but install the most current version from the repository that matches up with the Python you are using. Matplotlib 3.1.3 (and its dependencies) should be fully compatible with Python 3.8.3 on Windows 10.

PS C:\Users\jeff> .\testenv\Scripts\activate
(testenv) PS C:\Users\jeff> pip install matplotlib

MatplotLib has a huge number of dependecies and specific version of tools, so you would have to uninstall the current version of Python «setuptools» library and install an earlier version of setuptools that matches to matplotlib 2.2.2.

Too much work, in my opinion!

BELOW, I reproduced your error. In a «pristine» virtual environment of Python 3.8

PS C:\Users\jeff> .\testenv\Scripts\activate
(testenv) PS C:\Users\jeff> pip install matplotlib==2.2.2
Collecting matplotlib==2.2.2
  Downloading matplotlib-2.2.2.tar.gz (37.3 MB)
     |████████████████████████████████| 37.3 MB 2.2 MB/s
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\jeff\testenv\Scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\jeff\\AppData\\Local\\Temp\\pip-install-6vtzvs3l\\matplotlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\jeff\\AppData\\Local\\Temp\\pip-install-6vtzvs3l\\matplotlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\jeff\AppData\Local\Temp\pip-pip-egg-info-m4egguly'
         cwd: C:\Users\jeff\AppData\Local\Temp\pip-install-6vtzvs3l\matplotlib\
    Complete output (61 lines):
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [2.2.2]
                    python: yes [3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020,
                            23:03:10) [MSC v.1916 64 bit (AMD64)]]
                  platform: yes [win32]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [not found. pip may install it below.]
          install_requires: yes [handled by setuptools]
                    libagg: yes [pkg-config information for 'libagg' could not
                            be found. Using local copy.]
                  freetype: no  [The C/C++ header for freetype
                            (freetype2\ft2build.h) could not be found.  You may
                            need to install the development package.]
                       png: no  [The C/C++ header for png (png.h) could not be
                            found.  You may need to install the development
                            package.]
                     qhull: yes [pkg-config information for 'libqhull' could not
                            be found. Using local copy.]

    OPTIONAL SUBPACKAGES
               sample_data: yes [installing]
                  toolkits: yes [installing]
                     tests: no  [skipping due to configuration]
            toolkits_tests: no  [skipping due to configuration]

    OPTIONAL BACKEND EXTENSIONS
                    macosx: no  [Mac OS-X only]
                    qt5agg: no  [PySide2 not found; PyQt5 not found]
                    qt4agg: no  [PySide not found; PyQt4 not found]
                   gtk3agg: no  [Requires pygobject to be installed.]
                 gtk3cairo: no  [Requires cairocffi or pycairo to be installed.]
                    gtkagg: no  [Requires pygtk]
                     tkagg: yes [installing; run-time loading from Python Tcl /
                            Tk]
                     wxagg: no  [requires wxPython]
                       gtk: no  [Requires pygtk]
                       agg: yes [installing]
                     cairo: no  [cairocffi or pycairo not found]
                 windowing: yes [installing]

    OPTIONAL LATEX DEPENDENCIES
                    dvipng: no
               ghostscript: no
                     latex: no
                   pdftops: no

    OPTIONAL PACKAGE DATA
                      dlls: no  [skipping due to configuration]

    ============================================================================
                            * The following required packages can not be built:
                            * freetype, png
                            * Please check http://gnuwin32.sourceforge.net/packa
                            * ges/freetype.htm for instructions to install
                            * freetype
                            * Please check http://gnuwin32.sourceforge.net/packa
                            * ges/libpng.htm for instructions to install png
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Below is what the successful install looks like—

(testenv) PS C:\Users\jeff> pip install matplotlib
Collecting matplotlib
  Downloading matplotlib-3.3.1-cp38-cp38-win_amd64.whl (8.5 MB)
     |████████████████████████████████| 8.5 MB 2.2 MB/s
Collecting python-dateutil>=2.1
  Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting pillow>=6.2.0
  Downloading Pillow-7.2.0-cp38-cp38-win_amd64.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 1.7 MB/s
Collecting numpy>=1.15
  Downloading numpy-1.19.1-cp38-cp38-win_amd64.whl (13.0 MB)
     |████████████████████████████████| 13.0 MB 2.2 MB/s
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Collecting certifi>=2020.06.20
  Downloading certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
     |████████████████████████████████| 156 kB 3.3 MB/s
Collecting kiwisolver>=1.0.1
  Downloading kiwisolver-1.2.0-cp38-none-win_amd64.whl (58 kB)
     |████████████████████████████████| 58 kB 2.6 MB/s
Collecting cycler>=0.10
  Using cached cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Collecting six>=1.5
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: six, python-dateutil, pillow, numpy, pyparsing, certifi, kiwisolver, cycler, matplotlib
Successfully installed certifi-2020.6.20 cycler-0.10.0 kiwisolver-1.2.0 matplotlib-3.3.1 numpy-1.19.1 pillow-7.2.0 pyparsing-2.4.7 python-dateutil-2.8.1 six-1.15.0

Guy Lorshbaugh

Excellent! Good to know. I suppose I should have suspected as much, compatibility-wise. I wanted to be sure there wasn’t some bigger issue I needed to be aware of. Thanks for your help!

Post Views: 270

Hello, if you have come across this post then definitely you are curious to know the facts:

  • Why your terminal is taking too much time to execute the installation and why the terminal is not responding after showing this message “Running setup.py install for matplotlib ... /“?
  • Another question might arise. Should I wait or close the terminal and give it another try.

So I am here to clear all of your doubts.

What to do after seeing this message for longer than usual “Running setup.py install for matplotlib … \”

After running this command pip3 install matplotlib  or pip install matplotlibyou may face this type of situation:

But do not worry at this stage if it’s taking longer than usual time.

What I did was:

  • Closed the terminal just thinking that I will retry. (But still waiting time was longer)
  • Then I searched over the internet and someone suggested upgrading these: pip3 install --upgrade pip (for python3 or simply use pip instead of pip3 if you are using Python 2) and pip install --upgrade setuptools.

I suggest you do not do these as these will not harm anything but no need to do these.

You are not getting any type of error, it’s just a delay for the system configuration.

Just wait for 5 minutes hardly. It will be installed fine.

After waiting for few times I got this result:

matplotlib install on mac

I know that this answer might be weird for some people. But I thought I should share this with people like me who faced the same issue.

Купил новый компьютер с Windows 10, материнская плата Asus, процессор Ryzen 3200 Vega, и тут началась пляска с бубнами:
— Установил Python 3.8.6 успешно
— Установил matplotlib через pip успешно
— При попытке кодинга с помощью этого плагина выходит следующая ошибка:

>>> import matplotlib.pyplot
Traceback (most recent call last):
File «», line 1, in
import matplotlib.pyplot
File «C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\__init__.py», line 174, in
_check_versions()
File «C:\Users\admin\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\__init__.py», line 159, in _check_versions
from . import ft2font
ImportError: DLL load failed while importing ft2font: Не найден указанный модуль.

Пробовал устанавливать с нуля Windows 10 на трех разных новых компьютерах и с процессорами Intel Core i3, i5 тоже не работает.
Переустановил Windows 10 на свой старый комп: мать Gigabyte, проц AMD Phenom, видео GeForce GT 710 — та же ерунда, как на скриншоте.
Что вообще происходить и как это решить?

5f86d7062ebed217385695.png

I’m not able to install matplotlib.
Windows 10, Python 3.9.5

C:\Windows\System32 is in PATH

Any idea how to solve this? Thanks.

This is the error after conda install matplotlib:

==============================

ERROR conda.core.link:_execute(699): An error occurred while installing package 'conda-forge::qt-5.12.9-h5909a2a_4'.
Rolling back transaction: done

LinkError: post-link script failed for package conda-forge::qt-5.12.9-h5909a2a_4
location of failed script: C:\ProgramData\Miniconda3\Scripts\.qt-post-link.bat
==> script messages <==
<None>
==> script output <==
stdout:         1 file(s) copied.

stderr: 'chcp' is not recognized as an internal or external command,
operable program or batch file.
'chcp' is not recognized as an internal or external command,
operable program or batch file.
'chcp' is not recognized as an internal or external command,
operable program or batch file.

return code: 1

==================================

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Как проверить звуковую карту на ноутбуке windows 7
  • Aero mode windows 10
  • Sql server 2008r2 windows server 2012 r2
  • Пропало окно ввода пароля windows 10
  • Включить защитник windows 10 утилита