machinetosh
machinetosh

Reputation: 19

Shell is selecting Python 2.7, but not 3.7

I have Python 3.7 and I had a Python 2.7.

But when I am using Python Launcher it uses 2.7 not 3.7.

How to use Python 3.7? OS - Mac OS.

Upvotes: 1

Views: 2002

Answers (3)

cdarke
cdarke

Reputation: 44434

In the Python Launcher menu, go to Preferences. You should see a text box called "Interpreter", in there insert the path to your python 3.7, for example:

/Library/Frameworks/Python.framework/Versions/3.7/bin/python3

You might also add that to your PATH environment variable and use python3 (and idle3) rather than plain python.

Upvotes: 0

Mattia Procopio
Mattia Procopio

Reputation: 671

There are several ways you can obtain this behavior, my preferred one is symlinking the python3 executable to python

sudo unlink /usr/bin/python
sudo ln -s /usr/bin/python3 /usr/bin/python

Another way would be using pyenv https://github.com/pyenv/pyenv

Be aware od the fact that if you do this and you have some scripts on your machine that use the shebang #! /bin/python and were written for py2, they may stop working

Upvotes: -1

Nipun Thennakoon
Nipun Thennakoon

Reputation: 3744

If you want python 3.7 as default when you run command python in terminal, you can add an alias in ~/.bashrc

alias python=python3.7

bashrc is a shell script that bash runs whenever it is started interactively. You can find bashrc in your home directory.

Upvotes: 2

Related Questions