简体   繁体   English

Python 3安装

[英]Python 3 installation

I installed python3 to my my late 2014 iMac through brew.sh and my terminal is still defaulting to an older version of python unless I specifically prompt it with the command python3. 我通过brew.sh在我的2014年末iMac上安装了python3,并且我的终端仍默认使用旧版本的python,除非我使用python3命令特别提示。 Is there any way I can fix this so that the terminal just automatically defaults to python3, without me having to type in python3 every single time? 有什么办法可以解决此问题,以使终端自动默认为python3,而无需每次都键入python3? I really need to run django, and the fact that my system is still defaulting to python 2.7 is really getting in the way. 我确实需要运行django,而我的系统仍默认使用python 2.7的事实确实给您带来了麻烦。 Is there perhaps any way I can uninstall the older version of python? 有什么办法可以卸载旧版本的python吗?

Yes, you should set up virtual environments for python 2.7.13 and python 3.6. 是的,您应该为python 2.7.13和python 3.6设置虚拟环境。 when you want to run python2, just activate the python 2 environments. 当您想运行python2时,只需激活python 2环境即可。 Same for python3. 与python3相同。

If you installed python using Anaconda, there are instructions in the Anaconda documentation for creating virtual environments. 如果您使用Anaconda安装了python,则Anaconda文档中有创建虚拟环境的说明。

If you did not use Anaconda, you can find instructions for creating virtual environments by googling on 'virtual environment python' and there are many hits. 如果您没有使用Anaconda,则可以通过在“ virtual environment python”上使用谷歌搜索找到创建虚拟环境的说明,并且点击率很高。

I would advise against deleting any version of python. 我建议不要删除任何版本的python。 Macs come with a version of python installed that it uses and should not be removed. Mac随附安装了可使用的python版本,因此不应删除。

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

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