I installed YAPF formatter for Python code. Installation was successfull, no errors. Python 2.7.12
pip install yapf
Can't figure out how to run it: when run yapf -h
, I get error 'unknown command'. Same when run python yapf -d file.py
Output of test commands:
$ type -a pip yapf
pip is /usr/bin/pip
bash: type: yapf: not found
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$ ls -l {~/.,/usr/}local/bin/yapf
ls: cannot access '/usr/local/bin/yapf': No such file or directory
-rwxrwxr-x 1 username username 213 Jul 25 00:17 /home/username/.local/bin/yapf
type -a pip yapf
andecho $PATH
andls -l {~/.,/usr/}local/bin/yapf
please? – Byte Commander Jul 25 '18 at 09:49pip install --user
, your executables end up in~/.local/bin
, which only recently got added to the default PATH environment variable. On vanilla 16.04 Ubuntu installations or older, this directory might be missing in there, so that you can't directly execute those as commands without specifying their location. More details in the post linked above. – Byte Commander Jul 25 '18 at 21:16sudo -H pip install yapf
), because then the executable is placed in/usr/local/bin
, which is on the default PATH. If you install it for the user only (pip install --user yapf
), it's placed in~/.local/bin
, which is not on the default PATH, but easy to add, as described in the linked post. You could also just e.g. make a link in~/bin
to your executables, as that folder gets added to the path automatically. – Byte Commander Jul 26 '18 at 08:04pip install yapf
, not viapip install --user yapf
. – minto Jul 26 '18 at 13:26sudo -H
. I think the--user
flag is the default in recent versions anyway. Also this is not YAPF specific, this is for all packages with an executable. – Timo Jul 27 '18 at 07:30~/.local/bin
to the $PATH environment variable as suggested, that helped. One note: when editing~/.profile
file, should I insert blank line between existing variables and my new path variable, or this doesn't matter? – minto Jul 27 '18 at 08:29