question:
In the server environment, when using the python command, the prompt: -bash: python: command not found
Check the server python version, usually in the /usr/bin directory. Enter the following command in the terminal:
find /usr/bin -iname 'python*'
Get the output:
/usr/bin/python3.10
/usr/bin/python3
reason:
Python is installed normally and no soft links are configured.
Solution
Create a soft link according to the python version. The command is as follows: (such as python3.10, change it to your own according to the version information)
ln -s /usr/bin/python3.10 /usr/bin/python
Sudo permissions may be required.
Enter python -V to verify:
Python 3.10.6
ls -l /usr/bin/python*
lrwxrwxrwx 1 root root 16 Jun 26 06:31 /usr/bin/python -> /usr/bin/python3
lrwxrwxrwx 1 root root 10 Aug 18 2022 /usr/bin/python3 -> python3.10
-rwxr-xr-x 1 root root 5912968 May 29 11:10 /usr/bin/python3.10
Others: if present
ln: failed to create symbolic link '/usr/bin/python': File exists
Just add an f to the command ln -sf
ln -sf /usr/bin/python3.10 /usr/bin/python