Error while installing matplotlib on Jetson AGX Xavier

I’m trying to install matplotlib in vertual env with python3.6:

pip3 install  matplotlib

And get the next error:

Collecting matplotlib
  Using cached matplotlib-3.3.4.tar.gz (37.9 MB)
    ERROR: Command errored out with exit status -4:
     command: /home/nvidia/Downloads/test_venv/env36/bin/python3.6 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ftao42ep/matplotlib_a920bda9f0b947c2b97469537fda63d7/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ftao42ep/matplotlib_a920bda9f0b947c2b97469537fda63d7/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'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-y7guzvv3
         cwd: /tmp/pip-install-ftao42ep/matplotlib_a920bda9f0b947c2b97469537fda63d7/
    Complete output (19 lines):
    
    Edit setup.cfg to change the build options; suppress output with --quiet.
    
    BUILDING MATPLOTLIB
      matplotlib: yes [3.3.4]
          python: yes [3.6.9 (default, Oct  8 2020, 12:12:24)  [GCC 8.4.0]]
        platform: yes [linux]
     sample_data: yes [installing]
           tests: no  [skipping due to configuration]
          macosx: no  [Mac OS-X only]
    
    running egg_info
    creating /tmp/pip-pip-egg-info-y7guzvv3/matplotlib.egg-info
    writing /tmp/pip-pip-egg-info-y7guzvv3/matplotlib.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-pip-egg-info-y7guzvv3/matplotlib.egg-info/dependency_links.txt
    writing namespace_packages to /tmp/pip-pip-egg-info-y7guzvv3/matplotlib.egg-info/namespace_packages.txt
    writing requirements to /tmp/pip-pip-egg-info-y7guzvv3/matplotlib.egg-info/requires.txt
    writing top-level names to /tmp/pip-pip-egg-info-y7guzvv3/matplotlib.egg-info/top_level.txt
    writing manifest file '/tmp/pip-pip-egg-info-y7guzvv3/matplotlib.egg-info/SOURCES.txt'
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/22/d4/e7ca532e68a9357742604e1e4ae35d9c09a4a810de39a9d80402bd12f50f/matplotlib-3.3.4.tar.gz#sha256=3e477db76c22929e4c6876c44f88d790aacdf3c3f8f3a90cb1975c0bf37825b0 (from https://pypi.org/simple/matplotlib/) (requires-python:>=3.6). Command errored out with exit status -4: python setup.py egg_info Check the logs for full command output.
  Using cached matplotlib-3.3.3.tar.gz (37.9 MB)

After it can’t install v.3.3.4 it try v.3.3.3 and so on and so on. I interrupt installation via ctrl+C.
It works ok with python3.7 but I have old project written in python3.6 and I need to work with this.
Any suggestion?

Hi,

Could you try it via apt-get?

$ sudo apt-get install python3-matplotlib

Thanks

When I try:

$ sudo apt-get install python3-matplotlib

It install matplotlib 2.1.1. and not in my virtual env but on host.

Hi,

Could you try to enable the host package with the command in the following topic?

Thanks.

Tried :

$ virtualenv env36 --system-site-packages
Running virtualenv with interpreter /usr/bin/python2
New python executable in /home/nvidia/env36/bin/python2
Also creating executable in /home/nvidia/env36/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.

But from venv it does not see:

$ python3 
Python 3.6.9 (default, Oct  8 2020, 12:12:24) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'matplotlib'

Checked at host it works.

Hi,

Have you installed it outside of the virtualenv first?
Could you test if you can import the module correctly without using virtualenv?

Thanks.

Hi,
Yes, of course I checked outside matplotlib is installed and it works. I checked via

python3
>>> import matplotlib

And it’s ok

Hi,

Just double check it on Xavier with JetPack 4.5.1.
matplotlib can be loaded without issue.

nvidia@Xavier32G:~$ export DISPLAY=:0
nvidia@Xavier32G:~$ xhost +
access control disabled, clients can connect from any host
nvidia@Xavier32G:~$ source env36/bin/activate
(env36) nvidia@Xavier32G:~$ python3 
Python 3.6.9 (default, Oct  8 2020, 12:12:24) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>>

Thanks.