Reputation: 1145
Main problem:
I've installed recently Python3.3 - If I run now in Terminal: python script.py
(where script.py is coded in version 3.3) I'll get a python 2.7 output e.g.:
print('String',Var) --> ('String',Var)
Instead of:
print('String, Var) --> String Var
How can I uninstall Python 2.7 easily with Macport (without reading through Shell commands (time restriction)?) This one didn't worked.
Second (smaller) problem:
If I type in Terminal python
, I'll get python2.7 idle as output. How can I change this, so that command python refers to python3.3 (instead of using the command python3)
(About me: Python2.7 novice, absolutely no Shell knowledge, OS X 10.8.4 User, Xcode and Macport installed.)
Upvotes: 4
Views: 9097
Reputation: 426
I agree that it is bad idea to uninstall Python 2.7, just use following commands:
To list available Python versions:
port select --list python
To select desired version:
sudo port select python desired_version_from_list
This is proper and easy way to do it in MacPorts.
Upvotes: 3
Reputation: 2836
DON'T UNINSTALL PYTHON!!
It will mess up everything --> may be crash your OS. I tried that in Fedora 17 and it failed my package manager as yum is build in Python. One many great thing about Python is it supports multiple versions at once in the same platform which you already experienced.
Now, to resolve your problem do Edgar suggested.
Also, while writing your python code do this:
#!/usr/bin/env python3
print('Hello world!')
Then,
python hello.py
would run code in python3.
Upvotes: 0
Reputation:
Bad idea to uninstall the pre installed version of python. Better idea is to alias python to whatever you want in your bashrc/bash_profile.
In your home directory, aka ~, you might already have a .bash_profile
(If you don't have one, you can make it). You can edit that with your favorite text editor and add alias python='python3'
Or whatever you want called whenever you type python into bash.
(FWIW Homebrew is the new hotness, you might want to look into it as well)
Upvotes: 7