Dnaiel Dnaiel - 27 days ago 22
Python Question

change python version in terminal and intelliJ

short Q,

In a mac OS sierra terminal,

If I do:

whereis python
/usr/bin/python


Then if I do:
/usr/bin/python
it opens python 2.10

but if I execute
python
it opens python 2.7.8.
and this one comes from
/Library/Frameworks/Python.framework/Versions/2.7/bin/python


How do I change the default python to point to python 2.7.8? In the terminal and in intelliJ?

wim wim
Answer

Check the PATH environment variable with

echo $PATH

The python version you get when typing bare 'python' will be the first one found in that list of directories.

It is possible to control which python version is launched by, for example, rearranging the entries in PATH or by adding a symbolic link to the desired version in a position before the current version.

However, a more popular way to manage multiple python versions on the same machine is to use virtualenv. This will give you much less headaches when using pip to install/uninstall packages for particular python versions.