I am currently running OS X Yosemite (10.10.2) on my MacBook Pro... By default, Apple ships Python 2.7.6 on Yosemite.
我目前在MacBook Pro上运行OS X Yosemite(10.10.2)...默认情况下,Apple在Yosemite上运行Python 2.7.6。
Just downloaded and ran this installer for Python 3: python-3.4.3-macosx10.6.pkg
刚刚下载并运行了Python 3的安装程序:python-3.4.3-macosx10.6.pkg
When I opened up my Terminal and typed in python
, this is what came up:
当我打开终端并键入python时,这就是出现的结果:
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Question(s):
- Does anyone know where the Python 3.4.3 interpreter was installed?
- Do I need to uninstall Python 2.7.3 (if so, how do I go about doing this) before setting a global environmental variable such as PYTHON_HOME to the location of the installed Python 3.4.3?
有谁知道Python 3.4.3解释器的安装位置?
在将全局环境变量(如PYTHON_HOME)设置为已安装的Python 3.4.3的位置之前,是否需要卸载Python 2.7.3(如果是这样,我该怎么做)?
5 个解决方案
#1
57
Try typing python3
instead of just python
.
尝试输入python3而不是python。
#2
8
While @rhombidodecahedron's answer is concise and to-the-point and @Nacho Izquierdo addresses your first question perfectly, my answer aims to answer your second question in some more detail:
虽然@ rhombidodecahedron的答案简明扼要,而@Nacho Izquierdo完美地解决了您的第一个问题,但我的答案旨在更详细地回答您的第二个问题:
One should not uninstall Python 2.7 which comes with Mac OS X; it is supplied by Apple and is needed for applications running on OS X. It is stored in /System/Library/Frameworks/..
. If it is removed, Mac OS X will have to be reinstalled.
不应该卸载Mac OS X附带的Python 2.7;它由Apple提供,在OS X上运行的应用程序需要。它存储在/ System / Library / Frameworks / ...如果删除,则必须重新安装Mac OS X.
Hope that helps! And to reiterate answers given by @rhombidodecahedron and @Nacho Izquierdo, install Python 3.x separately and use python3
if you would like to use that version.
希望有所帮助!并重申@rhombidodecahedron和@Nacho Izquierdo给出的答案,分别安装Python 3.x并使用python3如果你想使用该版本。
Python 2.7 is the standard, Python 3.x is the future.
Python 2.7是标准,Python 3.x是未来。
#3
6
In order to use Python 3.x, type python3
instead of python
.
要使用Python 3.x,请键入python3而不是python。
#4
2
In the version OS X El Capitan, you can find the interpreter in: /opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4
在OS X El Capitan版本中,您可以在以下位置找到解释器:/opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4
By dragging this path into the Terminal and pressing enter you will be able to run this version.
通过将此路径拖入终端并按Enter键,您将能够运行此版本。
To run it faster you can either create an alias by typing in the Terminal: alias python = 'python3.4'
.
要更快地运行它,您可以通过键入Terminal:alias python ='python3.4'来创建别名。
#5
1
You can easily do this using pyenv which is a Simple Python Version Management. It allows one to set specific Python versions to run on specific directories or one can change your version before using shell
您可以使用pyenv轻松完成此操作,pyenv是一个简单的Python版本管理。它允许设置特定的Python版本在特定目录上运行,或者可以在使用shell之前更改您的版本
i.e.
$ pyenv install 2.7.6
$ pyenv install 2.6.8
$ pyenv local 2.7.6
$ pyenv versions
system
2.6.8
* 2.7.6 (set by /home/yyuu/.pyenv/version)
#1
57
Try typing python3
instead of just python
.
尝试输入python3而不是python。
#2
8
While @rhombidodecahedron's answer is concise and to-the-point and @Nacho Izquierdo addresses your first question perfectly, my answer aims to answer your second question in some more detail:
虽然@ rhombidodecahedron的答案简明扼要,而@Nacho Izquierdo完美地解决了您的第一个问题,但我的答案旨在更详细地回答您的第二个问题:
One should not uninstall Python 2.7 which comes with Mac OS X; it is supplied by Apple and is needed for applications running on OS X. It is stored in /System/Library/Frameworks/..
. If it is removed, Mac OS X will have to be reinstalled.
不应该卸载Mac OS X附带的Python 2.7;它由Apple提供,在OS X上运行的应用程序需要。它存储在/ System / Library / Frameworks / ...如果删除,则必须重新安装Mac OS X.
Hope that helps! And to reiterate answers given by @rhombidodecahedron and @Nacho Izquierdo, install Python 3.x separately and use python3
if you would like to use that version.
希望有所帮助!并重申@rhombidodecahedron和@Nacho Izquierdo给出的答案,分别安装Python 3.x并使用python3如果你想使用该版本。
Python 2.7 is the standard, Python 3.x is the future.
Python 2.7是标准,Python 3.x是未来。
#3
6
In order to use Python 3.x, type python3
instead of python
.
要使用Python 3.x,请键入python3而不是python。
#4
2
In the version OS X El Capitan, you can find the interpreter in: /opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4
在OS X El Capitan版本中,您可以在以下位置找到解释器:/opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4
By dragging this path into the Terminal and pressing enter you will be able to run this version.
通过将此路径拖入终端并按Enter键,您将能够运行此版本。
To run it faster you can either create an alias by typing in the Terminal: alias python = 'python3.4'
.
要更快地运行它,您可以通过键入Terminal:alias python ='python3.4'来创建别名。
#5
1
You can easily do this using pyenv which is a Simple Python Version Management. It allows one to set specific Python versions to run on specific directories or one can change your version before using shell
您可以使用pyenv轻松完成此操作,pyenv是一个简单的Python版本管理。它允许设置特定的Python版本在特定目录上运行,或者可以在使用shell之前更改您的版本
i.e.
$ pyenv install 2.7.6
$ pyenv install 2.6.8
$ pyenv local 2.7.6
$ pyenv versions
system
2.6.8
* 2.7.6 (set by /home/yyuu/.pyenv/version)