/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
How to Declare Custom Exceptions in Modern Python
How to Get a Function Name as a String
How to Delete a File or Folder in Python
Equivalent to Gettickcount() on Linux
Find "Home Directory" in Python
"E: Unable to Locate Package Python-Pip" on Ubuntu 18.04
Gae " No Attribute 'Httpshandler' " Dev_Appserver.Py
Python Sigkill Catching Strategies
Cannot "Pip Install Cryptography" in Docker Alpine Linux 3.3 with Openssl 1.0.2G and Python 2.7
Create Single Python Executable Module
Difference Between Python'S Generators and Iterators
Find Nearest Value in Numpy Array
How to Find the Owner of a File or Directory in Python
Pip Is Not Working for Python 3.10 on Ubuntu
Can You Fool Isatty and Log Stdout and Stderr Separately