Skip to content Skip to sidebar Skip to footer

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. a

Solution 1:

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.

Solution 2:

As wim mentioned you will get the first python that is found in $PATH.

A nice way may be to ln -s /Library/Frameworks/Python.framework/Versions/2.7/bin/python /usr/local/bin/python. This will create a symbolic link in /usr/local/bin

That way you don't change the order in your $PATH variable. Also note that if you echo $PATH, /usr/local/bin should be before /usr/bin - in case you have other versions in /usr/bin (which you do given your example)

I would strongly recommend you do what wim mentioned and use virtualenv to manage you packages.

Post a Comment for "Change Python Version In Terminal And Intellij"