Reputation: 117
I have only installed Python3.6 on my Mac. I have also installed miniconda. Whether I run the command:
$python -V
in my home directory, or a specific project directory, the output is Python 2.7.10. Why isn't it Python 3.6, and how can I change this default?
Upvotes: 2
Views: 1613
Reputation: 56627
Really it depends on the system what the behavior is. See PEP 394 for more, but roughly speaking,
python2
should always point you to Python 2.xpython3
should always point you to Python 3.xpython
on most distributions today will point to Python 2.xpython
might be overridden to point to Python 3.xpython
can point to either, depending how it was set upSo in other words, if you want to not really worry about it, use python2
and python3
commands instead of python
.
Although, macOS violates this pattern by installing python
without a python2
link (there is a python2.7
link, though).
Upvotes: 2
Reputation: 748
Probably what happened is that you have 2 versions of Python in your environment:
For some reason the environment variable for the python command is set to the 2.7.10 one, so in your shell the python command refers to the 2.7 version, if you want it to point to the 3.6 one you need to update the path variable for the python command.
If you want to manage more environments i suggest you to use Anaconda/miniconda and setting up virtual environments for both python 2 and 3, so you can switch between the two.
If you are only interested in one version of python either use a conda distribution or plain Python, as mixing things often creates this kind of problems.
More info on managing virutal environments:
Python: http://docs.python-guide.org/en/latest/dev/virtualenvs/
Anaconda: https://conda.io/docs/user-guide/tasks/manage-environments.html
Upvotes: 2