简体   繁体   English

Python如何将默认版本从python 3.5更改回python 2.7

[英]Python How to change default version back from python 3.5 to python 2.7

Recently, I just installed anaconda3 for python3, it works well. 最近,我刚刚为python3安装了anaconda3,效果很好。 But then I found out that my python default version has been modified to python3.5 as well. 但是后来我发现我的python默认版本也已修改为python3.5。 When I type "python" in terminal, it appears like this 当我在终端中键入“ python”时,它看起来像这样

Python 3.5.1 |Anaconda 2.4.1 (x86_64)| (default, Dec  7 2015, 11:24:55)

So I go and check my bash_profile, and found why it has been changed to python3.5: 所以我去检查我的bash_profile,发现为什么将其更改为python3.5:

# Setting PATH for Python 3.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH

# added by Anaconda3 2.4.1 installer
export PATH="//anaconda/bin:$PATH"

# added by Anaconda3 2.4.1 installer
export PATH="/Users/chengluli/anaconda/bin:$PATH"

# added by Anaconda3 2.4.1 installer
export PATH="/Users/chengluli/anaconda/bin:$PATH"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
eval "$(rbenv init -)"

After I commented all the texts related to python3.5 and anaconda3. 在我评论了所有与python3.5和anaconda3相关的文本之后。 The default changes to python2.7. 默认更改为python2.7。

However, the problem I have now is anaconda3 is not working. 但是,我现在遇到的问题是anaconda3无法正常工作。 When I type ipython notebook, error occurs. 当我键入ipython notebook时,会发生错误。

So I wonder how can I change default python version while having anaconda3 work properly? 所以我想知道如何在使anaconda3正常工作的同时更改默认的python版本? Or anaconda3 can only work when the default is python3.5. 或anaconda3仅在默认值为python3.5时才能工作。 So I need to use anaconda2 instead? 所以我需要改用anaconda2吗? Thanks in advance! 提前致谢!

You could change the alias for the current user or create a new symlink to make it systemwide. 您可以更改当前用户的别名或创建新的符号链接以使其在系统范围内。

More information and Debian examples can be found here https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux 更多信息和Debian示例可以在这里找到https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux

Download Anaconda2 instead, which uses Python 2.7. 而是下载使用Python 2.7的Anaconda2。

When you removed the anaconda path .bashrc you removed ipython and all the other binaries from the system path. 当您删除anaconda路径.bashrc时,您还从系统路径中删除了ipython和所有其他二进制文件。 They're still on your system but you can't run them by just typing ipython , you'd have to run them from their location ./anaconda3/bin/ipython or equivalent 它们仍然在您的系统上,但是您不能仅通过输入ipython来运行它们,而必须从它们的位置./anaconda3/bin/ipython或同等位置运行它们

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM