Can't install seaborn

Hi,

sudo python3 -m pip install --user --no-binary :all: seaborn

returns

ERROR: Failed building wheel for scipy
  Running setup.py clean for scipy
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-a8ap_657/scipy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-a8ap_657/scipy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' clean --all
       cwd: /tmp/pip-install-a8ap_657/scipy
  Complete output (9 lines):

  `setup.py clean` is not supported, use one of the following instead:

    - `git clean -xdf` (cleans all files)
    - `git clean -Xdf` (cleans all versioned files, doesn't touch
                        files that aren't checked into the git repo)

  Add `--force` to your command to use it anyway if you must (unsupported).

  ----------------------------------------
  ERROR: Failed cleaning build dir for scipy
Failed to build scipy
Skipping wheel build for seaborn, due to binaries being disabled for it.
ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly

It seems that an issue with scipy installation takes place;

ERROR: Failed cleaning build dir for scipy
ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly

probably some disc access permissions could cause it.
However, you may like to check a reference thread and install scipy ,

sudo apt-get install python3-scipy

then repeat.
https://devtalk.nvidia.com/default/topic/1054938/jetson-nano/install-scipy-on-jetson-nano/

sudo apt install python3-seaborn

should work if you’re ok with the version built by Canonical.

If you want a user install of the most recent version from pypi you can do:

pip3 install seaborn

With no sudo, and no --user

It will take a while to build, however, and you must have the required dependencies. You can probably ensure this with ‘apt-get build-dep python3-seaborn’, but you must uncomment the source URIs (deb-src lines) in your /etc/apt/sources.list and run apt update first.

Ok ty.

pip3 install seaborn

return the same error.

the only command which works is

sudo apt-get install python3-scipy python3-seaborn

Can’t figure out why it “can’t build the wheels” though.

Now :

>>> import seaborn
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/seaborn/__init__.py", line 6, in <module>
    from .rcmod import *
  File "/usr/lib/python3/dist-packages/seaborn/rcmod.py", line 8, in <module>
    from . import palettes, _orig_rc_params
  File "/usr/lib/python3/dist-packages/seaborn/palettes.py", line 12, in <module>
    from .utils import desaturate, set_hls_values, get_color_cycle
  File "/usr/lib/python3/dist-packages/seaborn/utils.py", line 8, in <module>
    from scipy import stats
  File "/usr/lib/python3/dist-packages/scipy/stats/__init__.py", line 348, in <module>
    from .stats import *
  File "/usr/lib/python3/dist-packages/scipy/stats/stats.py", line 177, in <module>
    from . import distributions
  File "/usr/lib/python3/dist-packages/scipy/stats/distributions.py", line 13, in <module>
    from . import _continuous_distns
  File "/usr/lib/python3/dist-packages/scipy/stats/_continuous_distns.py", line 15, in <module>
    from scipy._lib._numpy_compat import broadcast_to
  File "/usr/lib/python3/dist-packages/scipy/_lib/_numpy_compat.py", line 10, in <module>
    from numpy.testing.nosetester import import_nose
ModuleNotFoundError: No module named 'numpy.testing.nosetester'
>>> import numpy
>>> import scipy
>>> scipy.__version__
'0.19.1'
>>> seaborn.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'seaborn' is not defined
>>> numpy.__version__
'1.18.1'

apparently I have to install a higher version of scipy like this:

pip3 install scipy==1.1.0

Unfortunately “building wheel for scipy” …

When you install from pip, sometimes, if a pre-built version does not exist for your exact platform (like aarch64) it will build binary components from source, in which case it needs to have build dependencies (various language compilers, libraries, headers, etc…). Usually these requirements are listed in the documentation, but you can also use trial an error. For example:

With “pip3 install seaborn” I got an error about a fortran compiler not being installed, so I installed “gfortran” with apt-get. I reran the build, it went further, this time “pybind11-dev” is missing, so I apt installed that and restarted the pip install again. And so on and so forth. Eventually it builds. This process can be used to build just about anything. In any case it should not be used in combination with sudo.

Please note that on Ubuntu (and Linux_for_Tegra) a --user install is now the default for pip when run as a regular user, so you don’t need to use the flag anymore.

The easiest thing to do is usually use apt-get to install the python packages. Most are in Canonical’s repositories so you can “sudo apt install python-thing (or) python3-thing” where “thing” is whatever you would normally pip install.

Sometimes packages are slightly out of date, but often it’s better to develop for slightly older versions of packages since you can’t always depend on whoever installs your software to have the latest thing, and requiring it means they have to go through all of the above.

Are you sure? :

pip install scipy==1.1.0
Successfully built scipy
Installing collected packages: scipy
  Found existing installation: scipy 0.19.1
    Uninstalling scipy-0.19.1:
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: 'common.py'
Consider using the `--user` option or check the permissions.
$pip3 install --user scipy==1.1.0
Processing ./.cache/pip/wheels/a3/f6/1b/5f3b452380592395b4754ab4356cfae2eaa020303e8fc5e070/scipy-1.1.0-cp36-cp36m-linux_aarch64.whl
Requirement already satisfied: numpy>=1.8.2 in ./.local/lib/python3.6/site-packages (from scipy==1.1.0) (1.18.1)
Installing collected packages: scipy
Successfully installed scipy-1.1.0

Now it works perfectly. Thanks for your help.

As a test i just did a “pip3 install requests” on both my Xavier and Ubuntu box and it showed up in “~/.local/lib/python3.6/site-packages”, so I’m 99% sure. I found it documented on a github issue somwhere but I can’t find the reference rn :/

That is odd. Did you upgrade pip at some point from another source (like pip itself)? The user setting can also be overidden by a config file somewhere. Those could possibly be the cause or something else. In any case there is no harm to explicitly specifying --user.

I’m glad you have it working now. Enjoy!

Yes I actually downgraded it because of a bug to 20.0 -> 19.X

https://github.com/pypa/pip/issues/7620

I downloaded a get-pip.py and resintalled it.

I might might remove and reinstall from aptitude repo.

sudo apt remove python3-pip
sudo apt install python3-pip=19.3.1

So it should update env variable accordingly?

That is probably what did it. The version of pip installed through pypi is not the same as Canonical supplies in their apt repositories. When I do a “which pip3” i get “/usr/bin/pip3” and the --version is 9.0.1. It’s likely yours is somewhere else. You may have other issues with a pip that isn’t what the distro supplies, just FYI, however personally I’ve never had an issue upgrading pip in a venv.

Uninstalling it through apt-get won’t be possible since it wasn’t installed with apt-get, and reinstalling it won’t fix it if the upgraded pip is in a path that takes precedence, like /usr/local/bin or (i think) ~/bin or ~/.local/bin

Uninstalling it should be the reverse of however you installed it. If you do ‘which pip3’ and it’s not /usr/bin/pip3, you can probably just ‘pip3 uninstall pip’.

nano@nano-desktop:~$ pip3 uninstall pip
Uninstalling pip-19.3.1:
  Would remove:
    /usr/local/bin/pip
    /usr/local/bin/pip3
    /usr/local/bin/pip3.6
    /usr/local/lib/python3.6/dist-packages/pip-19.3.1.dist-info/*
    /usr/local/lib/python3.6/dist-packages/pip/*
Proceed (y/n)? y
ERROR: Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.6/shutil.py", line 550, in move
    os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/local/bin/pip' -> '/tmp/pip-uninstall-f41qhv8t/pip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 153, in _main
    status = self.run(options, args)
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/uninstall.py", line 79, in run
    auto_confirm=options.yes, verbose=self.verbosity > 0,
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/req/req_install.py", line 755, in uninstall
    uninstalled_pathset.remove(auto_confirm, verbose)
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/req/req_uninstall.py", line 394, in remove
    moved.stash(path)
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/req/req_uninstall.py", line 283, in stash
    renames(path, new_path)
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/utils/misc.py", line 338, in renames
    shutil.move(old, new)
  File "/usr/lib/python3.6/shutil.py", line 565, in move
    os.unlink(src)
PermissionError: [Errno 13] Permission denied: '/usr/local/bin/pip'
nano@nano-desktop:~$ sudo pip3 uninstall pip
[sudo] password for nano:
nanoSorry, try again.
[sudo] password for nano:
WARNING: The directory '/home/nano/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling pip-19.3.1:
  Would remove:
    /usr/local/bin/pip
    /usr/local/bin/pip3
    /usr/local/bin/pip3.6
    /usr/local/lib/python3.6/dist-packages/pip-19.3.1.dist-info/*
    /usr/local/lib/python3.6/dist-packages/pip/*
Proceed (y/n)? y
  Successfully uninstalled pip-19.3.1

That should do it. If you do “which pip3” now you should get “/usr/bin/pip3” rather than one in /usr/local/bin

which pip3 return nothing now and :

sudo apt install python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pip is already the newest version (9.0.1-2.3~ubuntu1.18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

and I cant use pip3 not recognized

Furthermore if I follow instruction from https://pip.pypa.io/en/stable/installing/ it’s the same way as before using get-pip.py to install pip.

So if I follow the instructions:

nano@nano-desktop:~$ python3 get-pip.py pip==19.3
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
Collecting pip==19.3
  Downloading pip-19.3-py2.py3-none-any.whl (1.4 MB)
     |████████████████████████████████| 1.4 MB 2.0 MB/s
Installing collected packages: pip
Successfully installed pip-19.3
nano@nano-desktop:~$
nano@nano-desktop:~$ which pip3
/home/nano/.local/bin/pip3

‘which pip3’ should return /usr/bin/pip3

If it doesn’t, at this point, you can try “sudo apt install --reinstall python3-pip” to force a reinstall of the default pip. If that still doesn’t work, I would suggest a reflash, since it’s likely to be the easiest way to fix the problem.

Also please see the page on installing with package managers

more direct link

There are, admittedly confusingly, a second set of instructions for systems with package managers like apt. Please see the relevant link in the post above.

I also found the reference to the --user default here:

And indeed it can be confusing.

nano@nano-desktop:~$ sudo apt install --reinstall python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 114 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic-updates/universe arm64 python3-pip all 9.0.1-2.3~ubuntu1.18.04.1 [114 kB]
Fetched 114 kB in 0s (872 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 150730 files and directories currently installed.)
Preparing to unpack .../python3-pip_9.0.1-2.3~ubuntu1.18.04.1_all.deb ...
Unpacking python3-pip (9.0.1-2.3~ubuntu1.18.04.1) over (9.0.1-2.3~ubuntu1.18.04.1) ...
Setting up python3-pip (9.0.1-2.3~ubuntu1.18.04.1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
nano@nano-desktop:~$ which pip5
nano@nano-desktop:~$ which pip3
/usr/bin/pip3
nano@nano-desktop:~$ pip3
-bash: /home/nano/.local/bin/pip3: No such file or directory

Ok I have to do then:

$/usr/bin/pip3 uninstall pip
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
$pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

by doing so it update the venv accordingly i guess
Thanks

As mentioned, a reflash is probably the ideal way to fix it, since your system is in an undefined state and it might be easier. It looks like pip got installed multiple times in multiple places, and that probably affected a lot of other things. You can try deleting ~/.local/bin/pip3 if it exists, logging out, and logging back in, but there is no guarantee you won’t have other issues.

If you create a venv and activate it, you can probably safely do a pip3 install --upgrade pip from inside the venv and you don’t have to do anything else.

Edit: ignore any instructions that were here, the’re not applicable to your setup.

Fixed instructions:

sudo apt install python3-virtualenv

Will install virtualenv itself. Then you can do this to create a venv called ‘potato’ and upgrade pip.

$ python3 -m virtualenv -p python3 potato
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/user/potato/bin/python3
Also creating executable in /home/user/potato/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
 $ source potato/bin/activate
(potato) $ pip3 install --upgrade pip
Requirement already up-to-date: pip in ./potato/lib/python3.6/site-packages (20.0.2)

It should be safe to modify anything inside that, however running get-pip.py might still break things. If you need to change the pip version you can do it through pip.