4

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.)

Community
  • 1
  • 1
Bython
  • 1,135
  • 1
  • 12
  • 21
  • "something about you" should come last if at all. It's commonly agreed that a brief summary of your actual problem should come first. – millimoose Aug 28 '13 at 13:01
  • Also, what I'd do is make sure wherever MacPorts installs things comes first on PATH, which should be set in `~/.profile`. Search various files starting with the dot character in your home folder for comments MacPorts generates. – millimoose Aug 28 '13 at 13:03
  • Also, I prefer Homebrew to MacPorts these days but that's an aside. (It tries more to be its own thing - an installer for command-line software and libraries - instead of emulating software intended to manage the configuration of an entire OS.) – millimoose Aug 28 '13 at 13:03

3 Answers3

7

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)

  • Thank you four your input, all problems solved and something new learned. – Bython Aug 28 '13 at 13:42
  • @Bython Always good to learn. Be sure to select this as your selected answer, if it is the correct answer for you. –  Aug 28 '13 at 13:46
3

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.

Lukasz
  • 426
  • 2
  • 13
0

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.

Joyfulgrind
  • 2,762
  • 8
  • 34
  • 41