3

I'm trying to install speedtest-cli with pip and I'm getting errors that speedtest-cli is not intalled.


ubuntu@vostro:~$ pip install --user speedtest-cli
Collecting speedtest-cli
  Using cached https://files.pythonhosted.org/packages/61/8b/58d1de9a7fff3e91c5ab956ab4ba72b49f42d9f73d5f3e248c740dfcc816/speedtest_cli-2.1.1-py2.py3-none-any.whl
Installing collected packages: speedtest-cli
Successfully installed speedtest-cli-2.1.1
ubuntu@vostro:~$ speedtest-cli
-bash: /usr/bin/speedtest-cli: No such file or directory

But speedtest-cli is correctly installed in /home/ubuntu/.local/lib/python2.7/site-packages and I can run it by doing python speedtest.py on that folder.

All those folders belong to the user ubuntu, but something I think is wrong is that the py and pyc files are not executable. (They weren't by default, I didn't change anything)

ubuntu@vostro:~/.local/lib/python2.7/site-packages$ ll
total 132K
drwxrwxr-x 2 ubuntu ubuntu 4,0K jun 02 2019 23:55 speedtest_cli-2.1.1.dist-info
-rw-rw-r-- 1 ubuntu ubuntu 1,2K jun 02 2019 23:55 speedtest_cli.py
-rw-rw-r-- 1 ubuntu ubuntu  62K jun 02 2019 23:55 speedtest.py
-rw-rw-r-- 1 ubuntu ubuntu  590 jun 02 2019 23:55 speedtest_cli.pyc
-rw-rw-r-- 1 ubuntu ubuntu  56K jun 02 2019 23:55 speedtest.pyc

And this is the output of python -m site

ubuntu@vostro:~/.local/lib/python2.7/site-packages$ python -m site
sys.path = [
    '/home/ubuntu/.local/lib/python2.7/site-packages',
    '/usr/lib/python2.7',
    '/usr/lib/python2.7/plat-x86_64-linux-gnu',
    '/usr/lib/python2.7/lib-tk',
    '/usr/lib/python2.7/lib-old',
    '/usr/lib/python2.7/lib-dynload',
    '/usr/local/lib/python2.7/dist-packages',
    '/usr/lib/python2.7/dist-packages',
]
USER_BASE: '/home/ubuntu/.local' (exists)
USER_SITE: '/home/ubuntu/.local/lib/python2.7/site-packages' (exists)
ENABLE_USER_SITE: True

I think the problem is related to the env properties, but looking at that output I'm not so sure anymore.

Deses
  • 162
  • Did you previously install it without --user? It looks like it still thinks there's a global binary installed. pip install --user ... should install it to $HOME/.local/bin/speedtest-cli – SHawarden Jun 03 '19 at 00:31
  • No, I installed it with apt, but the version on the repos is very outdated. Later I found in https://askubuntu.com/a/269821/918690 that it's better to use the pip method. – Deses Jun 03 '19 at 00:45
  • You may need to close and re-open the terminal session to update the environment. – SHawarden Jun 03 '19 at 00:50
  • Oh my goodness, why didn't I think of that? Wow. You just made me realize that I've been going with the same terminal session for hours.

    So yes, it's fixed... thank you! If you post it as an answer I'll mark this as solved. :)

    – Deses Jun 03 '19 at 01:07

1 Answers1

4

You have moved from a system wide installation to a localized user installation of the application within the same terminal session without it updating its environment.

Your terminal is remembering the system wide installation path at /usr/bin/... and trying to run that.

You will need to close the terminal session and reconnect to obtain a fresh environment and $PATH contents.

(If there's a better way to do this directly from the command line, I'd love to know.)

SHawarden
  • 865
  • Thank you! I'm used to the Windows Command Line and I'm aware that whenever I change anything in the environment I should launch a fresh cmd, but I wasn't aware that the same applied to Linux and/or pip. – Deses Jun 04 '19 at 12:31