I was just doing this today, seems like clear documentation is scarce for people who want to keep some control over what's installed, and where.
Supposing you have run pip3 install whatever, it defaults to put stuff under ~/.local, as you know. Its customary in Unix to divide the file types, put the "runable" ones under ~/.local/bin.
In a terminal, type this to see your path now:
$ echo $PATH
Check that you do have the installed python stuff in ~/.local
$ ls -la ~/.local/bin
That confirms the executable files are there, or does for me. If those file permissions show "x" they are executable.
Now, add that directory to the path within the terminal
$ export PATH=~/.local/bin:$PATH
Check your path again to see the change. Please remember that is a temporary setting only for that terminal session. It does not apply to other terminals at the same time or in the future. It is a good place to test things.
After that, every program executable within ~/.local/bin should run if you type its name in the command line. There is no need to run "~/.local/bin/jupyter", for example. Just type "jupyter". No need for the "./" that you see sometimes, that's when you launch a program from the working directory which is not in the path.
If you later decide you want to make that permanent, so that ~/.local/bin is always in your PATH, you can do that by editing some environment configuration files. Depending on your setup, for example, in my home folder ".bashrc" file, the last line is "export PATH=$PATH:$HOME/bin". So I could put $HOME/local/bin on the front of that. Note I wrote out $HOME, not "~" in there. Then every time I use a BASH shell, PATH would be fixed. If you might use other shells, I think the right thing is to edit the ~/.profile instead. I think all shells in Ubuntu will source that file.
In my case, I installed several programs with pip3, such as jupyter. One way to make sure where that was installed into is to run
$ pip3 list
shows all of the packages available, not just ones installed by pip3.
$ pip3 show jupyter
In my case, for example:
---
Metadata-Version: 2.0
Name: jupyter
Version: 1.0.0
Summary: Jupyter metapackage. Install all the Jupyter components in one go.
Home-page: http://jupyter.org
Author: Jupyter Development Team
Author-email: jupyter@googlegroups.org
Installer: pip
License: BSD
Location: /home/pauljohn/.local/lib/python3.5/site-packages
Requires: nbconvert, ipykernel, ipywidgets, notebook, jupyter-console, qtconsole
Classifiers:
Intended Audience :: Developers
Intended Audience :: System Administrators
Intended Audience :: Science/Research
License :: OSI Approved :: BSD License
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
I don't want this to sound like a flame, but it may seem like an attack. I'd warn you to not eagerly follow advice that some people here will offer, to run "sudo pip3 xxx". Generally, you would rather run root installs only with Debian packages, not with pip3. If you run without the sudo, you are confining the danger to the user account. If you goof while running a script as root, you might scatter files all around your hard disk and regret it. Especially if other people log in and use that computer, avoid doing anything as root unless you are confident.
Also worth noting, that pip3 defaults to install into ~/.local, but that is not necessary. Read "man pip3", look for "-t" (--target). You can specify the install directory. I think that is nice because you can confine any damage to one other directory and delete it whenever you want. ~/.local might have other valuable things in it installed by other programs and you would rather not obliterate them. I think of ~/.local as a place more for settings than programs anyway.
ls -a
to havels
display hidden files and folders, too. – Florian Diesch Jul 16 '16 at 12:02ls -a ~/.local/bin
. If the output is long, please edit it into your question. – wjandrea Jul 16 '16 at 18:18~/.local/bin/piston
? – terdon Jul 18 '16 at 07:16~/.local/bin/
is already in $PATH on modern Ubuntu. – Aaron Franke Jan 09 '19 at 10:24