Проблема с установкой matplotlib в Python

Я пытаюсь установить matplotlib в Windows x64 с помощью python 3.9. Когда я делаю:

pip install matplotlib

Я получаю такую ​​ошибку:

ERROR: Command errored out with exit status 1:
 command: 'c:\program files\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Luca\\AppData\\Local\\Temp\\pip-install-zlfu5f08\\kiwisolver\\setup.py'"'"'; __file__='"'"'C:\\Users\\Luca\\AppData\\Local\\Temp\\pip-install-zlfu5f08\\kiwisolver\\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\Luca\AppData\Local\Temp\pip-pip-egg-info-mriih1bh'
     cwd: C:\Users\Luca\AppData\Local\Temp\pip-install-zlfu5f08\kiwisolver\
Complete output (44 lines):
WARNING: The wheel package is not available.
  ERROR: Command errored out with exit status 1:
   command: 'c:\program files\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Luca\\AppData\\Local\\Temp\\pip-wheel-pvxhkv11\\cppy\\setup.py'"'"'; __file__='"'"'C:\\Users\\Luca\\AppData\\Local\\Temp\\pip-wheel-pvxhkv11\\cppy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Luca\AppData\Local\Temp\pip-wheel-1s8s6o5r'
       cwd: C:\Users\Luca\AppData\Local\Temp\pip-wheel-pvxhkv11\cppy\
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for cppy
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
  File "c:\program files\python39\lib\site-packages\setuptools\installer.py", line 128, in fetch_build_egg
    subprocess.check_call(cmd)
  File "c:\program files\python39\lib\subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['c:\\program files\\python39\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\Luca\\AppData\\Local\\Temp\\tmpggz7lusd', '--quiet', 'cppy>=1.1.0']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Luca\AppData\Local\Temp\pip-install-zlfu5f08\kiwisolver\setup.py", line 59, in <module>
    setup(
  File "c:\program files\python39\lib\site-packages\setuptools\__init__.py", line 164, in setup
    _install_setup_requires(attrs)
  File "c:\program files\python39\lib\site-packages\setuptools\__init__.py", line 159, in _install_setup_requires
    dist.fetch_build_eggs(dist.setup_requires)
  File "c:\program files\python39\lib\site-packages\setuptools\dist.py", line 699, in fetch_build_eggs
    resolved_dists = pkg_resources.working_set.resolve(
  File "c:\program files\python39\lib\site-packages\pkg_resources\__init__.py", line 779, in resolve
    dist = best[req.key] = env.best_match(
  File "c:\program files\python39\lib\site-packages\pkg_resources\__init__.py", line 1064, in best_match
    return self.obtain(req, installer)
  File "c:\program files\python39\lib\site-packages\pkg_resources\__init__.py", line 1076, in obtain
    return installer(requirement)
  File "c:\program files\python39\lib\site-packages\setuptools\dist.py", line 758, in fetch_build_egg
    return fetch_build_egg(self, req)
  File "c:\program files\python39\lib\site-packages\setuptools\installer.py", line 130, in fetch_build_egg
    raise DistutilsError(str(e)) from e
distutils.errors.DistutilsError: Command '['c:\\program files\\python39\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\Luca\\AppData\\Local\\Temp\\tmpggz7lusd', '--quiet', 'cppy>=1.1.0']' returned non-zero exit status 1.
----------------------------------------ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Я попытался последовать всем советам, которые нашел здесь, но ошибка продолжает генерироваться.

Кто может мне помочь, пожалуйста?


person Community    schedule 09.10.2020    source источник


Ответы (4)


Из stacktrace кажется, что колесо не установлено

Попробуйте следующее

pip install wheel

затем беги

python setup.py bdist_wheel

Согласно документации PIP Wheel

Build System Interface¶
In order for pip to build a wheel, setup.py 
must implement the bdist_wheel command with the following syntax:

python setup.py bdist_wheel -d TARGET
This command must create a wheel compatible with the 
invoking Python interpreter, and save that wheel in the 
directory TARGET.

No other build system commands are invoked by the pip wheel command.
person Paddy Popeye    schedule 09.10.2020
comment
Когда я запускаю вторую инструкцию, появляется ошибка: python: не удается открыть файл 'C: \ WINDOWS \ system32 \ setup.py': [Errno 2] Нет такого файла или каталога - person ; 10.10.2020
comment
Когда я запускаю python setup.py bdist_wheel, возникает ошибка: python: не удается открыть файл 'C: \ WINDOWS \ system32 \ setup.py': [Errno 2] Нет такого файла или каталога - person ; 10.10.2020

Пытаться

pip install wheel 

затем попробуйте еще раз.

person Aldy syahdeini    schedule 09.10.2020
comment
Теперь проблема с подушкой :( - person ; 10.10.2020
comment
Pillow 8.0.0 теперь поддерживает Python 3.9: Pillow.readthedocs.io/en /stable/releasenotes/8.0.0.html - person Hugo; 16.10.2020

После установки колеса вам следует снова запустить команду pip install matplotlib.

В моем случае ошибка переходит в установку подушки, после того, как я успешно установил подушку, я, наконец, могу также установить matplotlib!

person user14426357    schedule 10.10.2020
comment
то мне нужно решить проблему с подушкой для установки matplotlib без ошибок? - person ; 10.10.2020
comment
Pillow 8.0.0 теперь поддерживает Python 3.9: Pillow.readthedocs.io/en /stable/releasenotes/8.0.0.html - person Hugo; 16.10.2020

У меня была такая же ошибка. После запуска pip install wheel я запустил установку с флагом --prefer-binary:

python -m pip install -U matplotlib --prefer-binary.

В документации говорится следующее:

Если эта команда приводит к компиляции Matplotlib из исходного кода и возникают проблемы с компиляцией, вы можете добавить --prefer-binary, чтобы выбрать новейшую версию Matplotlib, для которой есть предварительно скомпилированное колесо для вашей ОС и Python.

person Bas G    schedule 23.10.2020