Natasha
Natasha

Reputation: 6903

how to select a particular version of python from command prompt

By default, I know MAC uses the python version 2.7.10. I have python 3.7 installed. I became sure of it by typing

python3 --version

in terminal which shows 3.7.2.

I want to use python's secret module which is available for python 3.3x above. Now, when I type python in my terminal, I get the python 2.7x interpreter but I want to select python 3.7.2 as interpreter. How can I select the python 3.7.2 interpreter version?

Upvotes: 0

Views: 2673

Answers (1)

pnovotnyq
pnovotnyq

Reputation: 547

If both python 2 and python 3 are installed, python runs python 2 by default and python3 runs python 3. If only python 3 is installed, then python runs python 3. python and python3 are just shortcuts to the full path to the binary. Run which python and which python3 to see what they are. Therefore, typing the full path or creating an alias would be one way to select the interpreter that you want.
Another way would be running a specific version of python in a virtual environment. That way you also have complete control over the specific versions of packages that you might use.

Upvotes: 2

Related Questions