is the version of GCC that the Python(s) were built with, not the version of Python itself. That information should be on the previous line. For example:[GCC 4.2.1 (Apple Inc. build 5646)]
# Apple-supplied Python 2.6 in OS X 10.6
$ /usr/bin/python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
# python.org Python 2.7.2 (also built with newer gcc)
$ /usr/local/bin/python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Items in should always be or link to files supplied by Apple in OS X, unless someone has been ill-advisedly changing things there. To see exactly where the /usr/bin is linked to:/usr/local/bin/python
$ ls -l /usr/local/bin/python
lrwxr-xr-x 1 root wheel 68 Jul 5 10:05 /usr/local/bin/python@ -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python
In this case, that is typical for a python.org installed Python instance or it could be one built from source.
In unix (mac os X included) terminal you can do
which python
and it will tell you.
You could have multiple Python versions on your macOS.
You may check that by , command or type command, like:which
which -a python python2 python2.7 python3 python3.6
Or type in Terminal and hit Tab few times for auto completion, which is equivalent to:python
compgen -c python
By default /python commands points to the first binary found in pip environment variable depending what's actually installed. So before installing Python packages with Homebrew, the default Python is installed in PATH which is shipped with your macOS (e.g. Python 2.7.10 on High Sierra). Any versions found in /usr/bin (such as /usr/local) are provided by external packages./usr/local/bin
It is generally advised, that when working with multiple versions, for Python 2 you may use /python2 command, respectively for Python 3 you can use pip2/python3, but it depends on your configuration which commands are available.pip3
It is also worth to mention, that since release of Homebrew 1.5.0+ (on 19 January 2018), the formula has been upgraded to Python 3.x and a python formula will be added for installing Python 2.7. Before, python@2 formula was pointing to Python 2.python
For instance, if you've installed different version via Homebrew, try the following command:
brew list python python3
or:
brew list | grep ^python
it'll show you all Python files installed with the package.
Alternatively you may use or apropos command to locate more Python related files.locate python
To check any environment variables related to Python, run:
env | grep ^PYTHON
To address your issues:
Error: No such keg: /usr/local/Cellar/python
Means you don't have Python installed via Homebrew. However double check by specifying only one package at a time (like ).brew list python python2 python3
The locate database (
) does not exist./var/db/locate.database
Follow the advice and run:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
After the database is rebuild, you can use command.locate
Generally speaking, to see where things installed using will end up, you can runpython3 setup.py --user
python3 -m site
and look at the definition of .USER_BASE
However, in your case, judging by the error message you are getting, I strongly suspect that you are running when you should be running python.python3
In your Python interpreter, type the following commands:
>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\\Python25'
Also, you can club all these and use a single line command. Open cmd and enter following command
python -c "import os, sys; print(os.path.dirname(sys.executable))"
There are some fundamental differences between Python 2 and Python 3, such that both keep being developed side-by-side. P3 is not the successor to P2 like other software versions.
Latest Python 3 Release - Python 3.6.5 (2018-03-28)
Latest Python 2 Release - Python 2.7.14 (2017-09-16)
In development Python 3.7.0b3 (2018-03-29)
In development Python 2.7.15rc1 (2018-04-15)
Python documentation