Executable symbolic link results in "command not found"
68,501
Solution 1
You forgot the initial slash before bin/python
. This means /usr/bin/prj-python
now points to /usr/bin/bin/python
. What would you like it to point to exactly?
Solution 2
Things to check:
- Perform an
ls -l /usr/bin/prj-python
If it's like:lrwxrwxrwx (...) /usr/bin/prj-python -> bin/python
The file will actually be searched at /usr/bin/bin/python (that's what xralf tried to say). Fix:rm /usr/bin/prj-python
ln -s /full/path/to/your/python /usr/bin/python-prj
- If your
bin/python
is a shell script (aka. wrapper-script) check the #!-line (sometimes called shebang-line) at the first line. If there's a typo like#!/bin/bush
that will cause a not found error message also.
Author by
xralf
Updated on September 18, 2022Comments
-
xralf almost 2 years
I created a symbolic link (yesterday) like this:
sudo ln -s bin/python /usr/bin/prj-python
When I run:
prj-python file.py
I get:
prj-python: command not found
When I try creating the link again, I get:
ln: creating symbolic link `/usr/bin/prj-python': File exists
Why is that happening? My
$PATH
is:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/real/RealPlayer
-
xralf over 12 yearsThere is not initial slash. the
pwd
is/home/xralf/my_virtual_env
and it has subdirectorybin
withpython
command -
rvs over 12 yearsThan, you've forgot
$PWD/
beforebin
. -
xralf over 12 yearsThank you, this helped. I used this command as it was in the book.
-
xralf over 12 yearsthank you, your answer is even more careful and educational. Sorry I already accepted.
-
Ja8zyjits over 8 yearsthis helped a lot...most of the answers if found were about $PATH
-
Cedric almost 7 yearsI use an ln without a parameter . People should use ln -s indeed, thus creating a symbolic link.
-
Manwal over 5 yearsHelped, and I used
ln -s $PWD/python /usr/bin/python-prj
.$PWD
is used for getting full path.