Change the Python version on an explained MAC in less than 128 words

Mac OS 10.8 comes with Python 2.7 pre-installed by Apple. After installing version 3 of python via you find that the terminal python command has remained on version 2 and you want to change it In terminal:

python --version
Python 2.7.10

Python3 is no longer compatible with earlier versions. Programs calling 'python' probably wait for python2. If you already have programs and scripts that you don't even know they're waiting for python-python2, changing the python command could break the operation of these programs and scripts. You can then create a custom alias in your shell. The command depends on the shell, but you can try:

aka py - python3

To make the command persist with each start of the terminal you can edit the .bashrc file via the nano editor for example

nano .bashrc

The nano editor opens, you then add the line at the end of the file

aka py - python3

To get out of the editor the command is Ctrl x then Y and input to confirm the backup. The Terminal must then be closed and restarted to take this change into account in the next session.

To start a script or program recorded for example in with python 3 you then have to type the command:

Auteur / autrice

Retour en haut