I used the installer from http://www.python.org/download . The install appeared successful, and it dropped the Python 3.3 folder in my Applications directory. I ran the "Update Shell Profile.command" script it contained, and it prepended /Library/Frameworks/Python.framework/Versions/3.3/
to my path. Yet the Python
version in that directory appears to be 2.7.5.
/Library/Frameworks/Python.framework/Versions/3.3 ls
Headers Python Resources bin include lib share
/Library/Frameworks/Python.framework/Versions/3.3 Python --version
Python 2.7.5
Also, ls /usr/bin | grep python
ls /usr/bin | grep python
shows:
python
python-config
python2.5
python2.5-config
python2.6
python2.6-config
python2.7
python2.7-config
pythonw
pythonw2.5
pythonw2.6
pythonw2.7
What have I missed?
There are multiple problems here.
First, you should not be running Python
, the framework's executable. Framework executables aren't meant to be run, and it's really only a coincidence that this one happens to work.
Frameworks with programs meant to be run put them in a bin
directory somewhere—either outside the framework (like /usr/local/bin
) or inside it (like /Library/Frameworks/Foo.framework/Versions/XY/bin
). By default, Python 3.3 does the latter.
And the programs inside the bin
directory are all lowercased, not capitalized, so there is no Python
to run.
Next, on Mac, and on almost every other platform in the world besides Windows, the current working directory is not part of your PATH
. So, when you type Python --version
, that finds Python
somewhere on the PATH
. The fact that you happened to have an executable of that name in the current directory doesn't mean anything (except that it's confusing to you). If you really want to run that file (but again, you really don't), you have to write ./Python
instead.
Also, there is really no good reason to cd
into the framework directory in the first place. Sure, you could run the file you want, from there, with the appropriate relative pathname: bin/python3
, for example, but you don't want to.
Next, likely you're using a shell you already had running before installing Python 3.3. The Update Shell Profile.command
script can be used to add Python 3.3 to the PATH
for all future shells, or to spawn a new shell with that PATH
, but either way it will not affect any existing shells. To solve that, you just have to start a new shell.
Next:
ls /usr/bin | grep python
ls /usr/bin | grep python
shows:
The /usr/bin
directory is only for programs that are part of the OS. Programs you install yourself go in /usr/local/bin
, or somewhere else on your PATH, instead. The Python installer has an option (although it may be hidden, I can't remember…) to put launchers in /usr/local/bin
. And it also has an option—which you selected—to put its framework bin
directory onto your PATH
. But either way, it's never going to put anything in /usr/bin
.
And finally, even after installing Python 3.3, the default python
will still be 2.7. python3
and python3.3
will be 3.3, but python
and python2.7
will be 2.7. See PEP 394 — The "python" Command on Unix-Like Systems for the rationale. But the short version is, there's all kinds of code that depends on Python 2.7 and isn't compatible with 3.3 that may be installed on your system, and you don't want it all to stop working.
So, putting it all together:
python3 --version
. You may want to consider using a virtualenv:
$ /Library/Frameworks/Python.framework/Versions/3.3/bin/python3 -m venv ~/myvenv
$ source ~/myvenv/bin/activate
(myvenv) $ curl https://bootstrap.pypa.io/get-pip.py | python
(myvenv) $ deactivate
$ source ~/myvenv/bin/activate
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.