安裝好新的版本的Ubuntu 20.04.1 發現沒有 python 指令,剩下 python3,舊的 .py 檔案執行會顯示錯誤訊息:
/usr/bin/env: ‘python’: No such file or directory
解法:
A simple safe way would be to use an alias. Place this into ~/.bashrc
or ~/.bash_aliases
file:
alias python=python3
由於我是使用 oh my zsh, 所以修改是 ~/.zshrc 檔案
增加完成後,重開 Terminal 的視窗,不需 reboot,就可以套用到 shell script 的設定值。
明明有安裝python3了,怎麼會還出現錯誤訊息:
/usr/bin/env: ‘python’: No such file or directory
造成無法執行.py檔呢?
Problem scenario:
/usr/bin/env: ‘python’: No such file or directory
Possible Solution #1
- If Python 3 is not installed, install it:
apt-get install python3
Possible Solution #2
- If Python 3 has been installed, run these commands:
whereis python3
- Then we create a symlink to it:
sudo ln -s /usr/bin/python3 /usr/bin/python