/Usr/Bin/Env: Python2: No Such File or Directory

/usr/bin/env: python2: No such file or directory

Probably that's just true. The link /usr/bin/python2 -> (the real one) should be provided by your Python package, but that's obviously not the case, nor on any other location where it can be found via the $PATH.

You should put the said link in your path at the (an) appropriate place.

/usr/bin/env: python2.6: No such file or directory error

I think you might be confused about the location of your python executables, versus the location of the lib site-packages.

Your python site-packages should be here:

/usr/lib/python2.6/site-packages

But your executables should probably be here:

/usr/bin

If you run this following command, it should tell you where it is currently finding the executables:

which python
which python2.7
...

Your $PATH environment variable should contain paths that have executable files directly underneath.
i.e. $ echo $PATH
/usr/bin:/usr/local/bin:/home/aUser/bin

If your executable is in another location that is not in your path and you don't want to neccessarily add that location to your path, you can also just symlink it to somewhere normal....

ln -s /path/to/executable /usr/bin/executable

Here is a trick to find all the executable files named python:

find /usr -type f -name 'python*' -perm -a+x

This might help you locate python2.6

‘python’: No such file or directory when running Python file as executable

This message:

/usr/bin/env: ‘python’: No such file or directory

suggests that the hashbang in your script looks like this:

#!/usr/bin/env python

Since running the script explicitly with python3 worked OK, it sounds like you're on a distro where by default you only have python3 and no python. As other answers suggest, you may install python-is-python3 (which basically creates a python symlink pointing to python3). If you don't wish to do that, then just adjust the script's hashbang so that /usr/bin/env looks for python3:

#!/usr/bin/env python3

Getting usr/bin/python2.7: No such file or directory when it's there

If running python2.7 emits an error message containing the string usr/bin/python2.7 -- with no leading / -- there's something going on it your shell's runtime environment inserting the command; this is most likely a function or an alias.

If you run:

type python2.7

...it will emit something like:


python2.7 is aliased to 'usr/bin/python2.7'

(in which case you can clear it with unalias python2.7, and prevent it from being configured again by removing the line establishing that alias from your dotfiles -- typically, it'll often be in ~/.bashrc).


...or you may have a shell function, such as:

python2.7 is a function
python2.7 () {
usr/bin/python2.7 "$@"
}

(in which case you can use unset -f python2.7 to delete the function from your current shell, and again can look for and remove the line in your shell's dotfiles which define it in the first place)


...or you may have a wrapper script intercepting your Python interpreter, such as:

python2.7 is /home/you/bin/python2.7

(in which case you can open that script in an editor and fix it).

Duplicity on macos not working, getting: env: python2: No such file or directory

You can create a symlink, but it is better to create it in /usr/local/bin/ or somewhere else where your normal user account has access, rather than globally in /usr/bin/ (which requires root access to modify).

Personally, I find if your install brew and Python from brew, not only do you get the latest Python builds, but it also manages these path problems for you.

Read more about brew at https://brew.sh/



Related Topics



Leave a reply



Submit