Uninstall Python 2.7 on OSX 10.8.4

Main problem: I recently installed Python3.3. If I run now in Terminal: python script.py (where script.py is encoded in version 3.3), I get python 2.7 output, for example:

 print('String',Var) --> ('String',Var) Instead of: print('String, Var) --> String Var 

How can I easily remove Python 2.7 using Macport (without reading Shell commands (time limit)?) This did not work.

Second (smaller) problem: If I type Terminal python , I will get python2.7 as output. How can I change this so that the python command applies to python3.3 (instead of using the python3 command)

(About me: Python2.7 newbie, absolutely no knowledge of Shell, OS X 10.8.4. User, Xcode and Macport are installed.)

+4
source share
3 answers

It is a bad idea to remove the pre-installed version of python. A better idea is the python alias you want in your bashrc / bash_profile file.

In your home directory, aka ~, you may already have .bash_profile (if you do not have one, you can do this). You can edit this in your favorite text editor and add alias python='python3' Or whatever you want to call whenever you type python in bash.

(FWIW Homebrew is a new heat, you can also look into it)

+7
source

I agree that removing Python 2.7 is not bad, just use the following commands:
To view available versions of Python:

 port select --list python 

To select the desired version:

 sudo port select python desired_version_from_list 

This is the right and easy way to do this in MacPorts.

+1
source

DO NOT REMOVE THE PYTHON !!

This will ruin everything - maybe your OS may crash. I tried this in Fedora 17 and my package manager failed because yum is built in Python. One of the many great features of Python is that it supports multiple versions at once on the same platform that you have already experienced.

Now, to solve your problem, Edgar suggested.

Also, when writing Python code, do the following:

 #!/usr/bin/env python3 print('Hello world!') 

Then

python hello.py will run the code in python3.

0
source

Source: https://habr.com/ru/post/1499381/


All Articles