I installed python 3 and pip3 into in Windows System for Linux shell that uses Ubuntu, but it appears I have to find and specify site-packages or $HOME/.local/bin directory manually if I want to run any python package executables.

The package I want to use is cheat, but the problem is the same for any other package.

My chain of commands was:

  1. install WSL - Ubuntu 18.04
  2. sudo apt-get update (because sudo apt-get install pip3 will not work on fresh installation)
  3. sudo apt-get -y install python3-pip (installs python too) - edited
  4. sudo pip3 install cheat
  5. cheat not recognised as a command, while python3 runs fine from /usr/bin/python3
  6. find locations where cheat is found, they are:

  7. When I add any of these directories to path, I'm able to run python executables, cheat ls works.

Is there something I can change in the installation process so that I mustn't search for directories and add them manually to path?

  • I don't understand: ~/.local/bin is where pip usually installs executables for user-installation. You only need to know that once, there's no need to search for the location again and again. – muru Sep 27 '18 at 21:59
  • @muru - I'm saying that on a bare linux installation a user would have to search for ~/.local/bin to find out where the executable is, if he has no prior knowledge of pip behaviour. On Windows executables work right after pip install, no searching needed. – EPo Sep 28 '18 at 5:52
  • @muru - also not clear why sudo pip3 install cheat still installs to a user home directory. – EPo Sep 28 '18 at 5:53
  • all the more reason to be aware of the behavior of tools that download programs from the internet. As for sudo pip, I assumed you ran one command and pasted another here, because sudo pip installs binaries to /usr/local/bin, which is in PATH. – muru Sep 28 '18 at 6:05
  • @muru - do you care to post your last comment as an answer? This is really the case after I repeted my steps: sudo does install at /usr/local/bin/cheat and local directories installation emerges when doing pip with no sudo. – EPo Sep 29 '18 at 6:32

@muru provided proper diagnostics: the issue with local directories arises only when running pip3 install cheat.

When running sudo pip3 install cheat the package executable installs to /usr/local/bin/ which is on path.

For the rest of the question "Why did my local version of python package install to a directory which is not in path", the overall answer is close to "You have to know your system and folder structure", which equates to "Put ~/.local/bin/on path.

So reiterating to conclude - if you are installing a package with pip and you are not in sudo mode, you have to add ~/.local/bin/ to path to make package executable run.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.