最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Can't install matplotlib in Python 3.6 - Stack Overflow

programmeradmin4浏览0评论

I've created a Python 3.6 environment in my WSL Ubuntu 22.04 operating system using virtualenv -p python3.6 <my_env>. I need to download some packages, particularly matplotlib, but I'm having some problems.

When I run pip install matplotlib from terminal, it returns me ERROR: Command errored out with exit status 1, as it fails to build wheel for matplotlib, kiwisolver and pillow.

I can't upgrade the Python version.

I don't know what to do, I've tried everything I found online, but it's not working.

Output

Building wheel for matplotlib (setup.py) ... error  
  ERROR: Command errored out with exit status 1:  
   command: /home/andrea/Andrea/env/pyaneti_env/bin/python -u -c  'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3byxbnl0/matplotlib_5a7e3488d8ed4fa586ccee5566cd5543/setup.py'"'"'; __file__='"'"'/tmp/pip-install-3byxbnl0/matplotlib_5a7e3488d8ed4fa586ccee5566cd5543/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-e23pjohb  
       cwd: /tmp/pip-install-3byxbnl0/matplotlib_5a7e3488d8ed4fa586ccee5566cd5543/
  Complete output (1714 lines):  
[...]  
  AttributeError: install_layout  
  ERROR: Failed building wheel for matplotlib  

Analogue results for kiwisolver and pillow

I've created a Python 3.6 environment in my WSL Ubuntu 22.04 operating system using virtualenv -p python3.6 <my_env>. I need to download some packages, particularly matplotlib, but I'm having some problems.

When I run pip install matplotlib from terminal, it returns me ERROR: Command errored out with exit status 1, as it fails to build wheel for matplotlib, kiwisolver and pillow.

I can't upgrade the Python version.

I don't know what to do, I've tried everything I found online, but it's not working.

Output

Building wheel for matplotlib (setup.py) ... error  
  ERROR: Command errored out with exit status 1:  
   command: /home/andrea/Andrea/env/pyaneti_env/bin/python -u -c  'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3byxbnl0/matplotlib_5a7e3488d8ed4fa586ccee5566cd5543/setup.py'"'"'; __file__='"'"'/tmp/pip-install-3byxbnl0/matplotlib_5a7e3488d8ed4fa586ccee5566cd5543/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-e23pjohb  
       cwd: /tmp/pip-install-3byxbnl0/matplotlib_5a7e3488d8ed4fa586ccee5566cd5543/
  Complete output (1714 lines):  
[...]  
  AttributeError: install_layout  
  ERROR: Failed building wheel for matplotlib  

Analogue results for kiwisolver and pillow

Share Improve this question edited Mar 18 at 10:16 Matt Pitkin 6,6451 gold badge25 silver badges45 bronze badges asked Mar 17 at 13:36 Andrea BaroneAndrea Barone 296 bronze badges 7
  • have you updated the Ubuntu packages? Do you know what specific version of matplot lib you may need? You can always try something like pip install matplotlib==VERSION_NUM – UnsanitizedInput Commented Mar 17 at 13:44
  • Can you provide the full log of pip install? – link89 Commented Mar 17 at 13:48
  • I should have updated them using sudo apt update (I'm still not used to Ubuntu). I don't need any specific version, but I've already tried installing 3.2.1 and 3.3.4, and the results are the same. – Andrea Barone Commented Mar 17 at 13:53
  • The full log is pages long, here is the first part: Collecting matplotlib Using cached matplotlib-3.3.4.tar.gz (37.9 MB) Preparing metadata (setup.py) ... done Collecting cycler>=0.10 Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB) Collecting kiwisolver>=1.0.1 Using cached kiwisolver-1.3.1.tar.gz (53 kB) Preparing metadata (setup.py) ... done Requirement already satisfied: numpy>=1.15 in /home/andrea/Andrea/env/pyaneti_env/lib/python3.6/site-packages (from matplotlib) (1.19.5) [...] AttributeError: install_layout ERROR: Failed building wheel for matplotlib – Andrea Barone Commented Mar 17 at 13:58
  • 1 Do you specifically have to use the Python installation and virtualenv package installed from Ubuntu's package distribution? Can you instead use another virtual environment package like conda anaconda/docs/getting-started/miniconda/…, with which you could create a virtual environment using any Python version rather than just the Ubuntu provided version? I would recommend using conda if you can for this situation. – Matt Pitkin Commented Mar 18 at 10:27
 |  Show 2 more comments

2 Answers 2

Reset to default 0

One possible cause is an old setuptools version. Try this:

python3.6 -m pip install -U setuptools

Then retry installing matplotlib.

Here I am answering my own question.
After trying everything you and the internet suggested, I gave up on using virtualenv.

As Matt suggested in the comments, I downloaded miniconda and created an environment there. I was able to download all the packages and the code is running nicely.

Thanks for your help.

发布评论

评论列表(0)

  1. 暂无评论