Python translators on OS X Yosemite - which one to use?

I recently switched from Windows to Mac, and after installing PyCharm I had to specify an interpreter. In the drop-down list, I could choose between three interpreters:

  • Macintosh HD ▸ usr ▸ local ▸ Basement ▸ python ▸ 2.7.9 ▸ Frames ▸ Python.framework ▸ Versions ▸ 2.7 ▸ bin
  • Macintosh HD ▸ System ▸ Library ▸ Frames ▸ Python.framework ▸ Versions ▸ 2.7 ▸ bin
  • Macintosh HD ▸ System ▸ Library ▸ Frames ▸ Python.framework ▸ Versions ▸ 2.6 ▸ bin

(In fact, I can say that in this last folder there are versions 2.5 and 2.3, but they are not shown in PyCharm).

However, if I type pythonin the terminal and then type

import sys
print sys.executable

I get:

  1. /usr/local/opt/python/bin/python2.7

To make it even more confusing, when I type the same thing in an IPython laptop (it starts from a terminal using ipython notebook), I get:

  1. /usr/bin/python

Questions:

  • If I want to use Python 2.7 (I have 3 options), which one should I use?
  • How to move between these interpreters (if I want pip installon different)?
+4
source share
1 answer

You really only have two installations of Python 2.7, as well as Python version 2.6, which you can mostly ignore:

  • /usr/local/Cellar/set by user (via Homebrew ). It will be associated with the directory structure /usr/local/opt:

    $ /usr/local/bin/python -c "import sys; print sys.prefix"
    /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7
    

    c /usr/local/opt/pythonis a symbolic link to the directory Cellar:

    $ ls -la /usr/local/opt/python
    lrwxr-xr-x  1 mj  admin  22 Jan  5 18:36 /usr/local/opt/python -> ../Cellar/python/2.7.9
    

    Python /usr/local Python, , .

  • 2.7 - , OS X ( , , site-packages Python). /System/Library/Frameworks, /usr/bin/python /usr/bin/python2.7 - Python:

    $ /usr/bin/python -c "import sys; print sys.prefix"
    /System/Library/Frameworks/Python.framework/Versions/2.7
    
  • 2.6, - , OS X; Apple, , , , 2.3 2.5, 2.6 ( , ).

2.7, Homebrew; , 2.7.x. virtualenv , OS X 2.7. . PyCharm.

PyCharm , , . Project Interpreter.

IPython - Python, Python. , Python. , . OS X Python 2.7, brew ( pip, Python).

+12

Source: https://habr.com/ru/post/1569967/


All Articles