14
after installation with

pip3 install --user steem-piston
you will get a new executable piston installed in ~/.local/bin

I installed the tool using pip install, but I cannot find the executable file.

I'm not quite sure I understand what this directory is: ~/.local/bin.

Is it just root/local/bin?

3 Answers3

17

~/ is a shell abbreviation for your home folder, usually /home/USERNAME/, where USERNAME is the name of your user. It's the same as $HOME

~/.local/bin is a subfolder named bin in the subfolder named .local in your home folder.

You can use

~/.local/bin/pip3

to call your new pip3 executable. It may be easier to add ~/.local/bin to the $PATH environment variable, see How to add a directory to my path? so you don't need to type ~/.local/bin/ all the time.

Make sure you add it before the old value of $PATH, like

PATH="$HOME/.local/bin/:$PATH"
terdon
  • 100,812
  • Thank you for your post. Unfortunately, I can't see the subfolder in the home folder (is it a hidden file?). And when I type that command in terminal I get: bash: /home/myname/.local/bin/pip3: No such file or directory – TabulaSmaragdina Jul 16 '16 at 11:58
  • Yes, if the name of a file or folder starts with a dot it is hidden by default. You can use ls -a to have ls display hidden files and folders, too. – Florian Diesch Jul 16 '16 at 12:02
  • @TabulaSmaragdina It's odd that the file isn't found. Try running ls -a ~/.local/bin. If the output is long, please edit it into your question. – wjandrea Jul 16 '16 at 18:18
  • 1
    Don't you mean ~/.local/bin/piston? – terdon Jul 18 '16 at 07:16
  • 1
    Note: ~/.local/bin/ is already in $PATH on modern Ubuntu. – Aaron Franke Jan 09 '19 at 10:24
10

~/.local/bin has been added to the PATH in Ubuntu 16.10, and backported to 16.04. See https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1588562

If you're running Ubuntu >=16.04 with all updates, it should already be fine. If not, you can add it manually :

For a single user, edit the file ~/.profile, and add at its end :

PATH="$HOME/.local/bin:$PATH"

If you want any newly-created user to have this, you can add this same line at the end of /etc/skel/.profile

Mossroy
  • 1,276
0

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.

pauljohn32
  • 3,743