简体   繁体   中英

How to change python version (interactive mode) in macports?

[mac-120183:/opt/local/bin] name% sudo port select --set python python33
Selecting 'python33' for 'python' succeeded. 'python33' is now active.
[mac-120183:/opt/local/bin] name% python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[mac-120183:/opt/local/bin] name% which python
/usr/bin/python
[mac-120183:/opt/local/bin] name% which python3.3
/opt/local/bin/python3.3

How may I switch my python to python3.3 when I type python to use interactive mode in command line?

Thanks

The interpreter you get when you type python is included in OS X, which means programs written for OS X will expect python to be Python 2.7. Changing that is dangerous because it could break programs, and that's probably why macports isn't messing with it.

If you really want to, you can do it by putting Macports' bin directory before /usr/bin in your PATH :

export PATH=/path/to/macports/bin:$PATH

You should be able to find the correct path with which python33 .

You could also overwrite /usr/bin/python with a link to Python 3.3, but that's incredibly dangerous, and I don't recommend it.

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.

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