[英]Python: aliased to python3
I tried to upgrade python 2.7 to python 3 and I modified the file ~/.bash_aliases
but when I type python in elementary terminal I get this error我尝试将 python 2.7 升级到 python 3 并修改了文件
~/.bash_aliases
但是当我在基本终端中键入 python 时出现此错误
zsh: command not found: python3
and when I type which python当我输入 which python
python: aliased to python3
actually I prefer return to python 2.7 or if someone know how can I fix this:c实际上我更喜欢返回 python 2.7 或者如果有人知道我该如何解决这个问题:c
Go into your .zshrc file. 进入您的.zshrc文件。 Is there a line that reads:
是否有一行显示为:
alias python='python3'
If so, remove that line. 如果是这样,请删除该行。 Else, check if you can run
python2
, python2.7
, or something like that. 否则,检查是否可以运行
python2
, python2.7
或类似的东西。 If so, then just hack and add the line 如果是这样,那么只需修改并添加行
alias python='python2'
Or whatever your python2 is. 或无论您的python2是什么。 Else, type
否则,输入
sudo apt-get install python2.7
Or whatever is the appropriate method for installing programs on your system. 或在系统上安装程序的适当方法是什么。
Follow this steps if you are using macOS.如果您使用的是 macOS,请按照以下步骤操作。
brew install python
.brew install python
。 This will install the latest version of Python. If you want Python 2.7, do well to specify the version.brew info python
.brew info python
。 You will see a path similar to: /usr/local/opt/python@3.9/libexec/bin
/usr/local/opt/python@3.9/libexec/bin
$ echo 'export PATH="/usr/local/opt/python@3.9/libexec/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
source ~/.zshrc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.