3

I have two python 2.7's of interest:

I use MacOS. (I understand I'm overdue to switch to Python 3)

I'd like to apply pip install --upgrade PackageName to a package that IDLE's Python uses, but when I type that in my terminal it tries to apply it to my anaconda version.

Is there a way I can find my IDLE's python, point to it, then apply the pip command to it?

Here's what I have:

$ which python

/Users/david/anaconda2/bin/python

$ which -a python

/Users/david/anaconda2/bin/python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/bin/python
/usr/bin/python

update: Per this answer I've opened IDLE and typed

import sys
sys.executable

and it returned /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python.

I then opened a terminal and entered /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -m pip install --upgrade skyfield

and I received the following:

Cache entry deserialization failed, entry ignored
Could not fetch URL https://pypi.python.org/simple/skyfield/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
Requirement already up-to-date: skyfield in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Could not fetch URL https://pypi.python.org/simple/jplephem/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
Requirement already up-to-date: jplephem>=2.3 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from skyfield)
Could not fetch URL https://pypi.python.org/simple/sgp4/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
Requirement already up-to-date: sgp4>=1.4 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from skyfield)
Could not fetch URL https://pypi.python.org/simple/numpy/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
Requirement already up-to-date: numpy in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from skyfield)

I close IDLE then reopen it, then type

import skyfield
skyfield.__version__

and still it's only 1.0

No update.

Skyfield is currently on version 1.10 https://rhodesmill.org/skyfield/installation.html and I upgraded my anaconda version successfully today to 1.10 using pip install --upgrade skyfield

uhoh
  • 3,713
  • 6
  • 42
  • 95
  • I am guessing that anaconda does not directly use pypi as the repository for user upgrades. Open another SO question or post to python-list about the certificate issue. It has nothing to do with IDLE. – Terry Jan Reedy Feb 22 '19 at 21:38
  • @TerryJanReedy I'll think about posting a new question; I think I understand what you are saying, but I'm not confident I understand well enough to write a question and answer all comments. Thanks! – uhoh Feb 23 '19 at 02:29

2 Answers2

1

To find your IDLE's version, open IDLE, the go to the help section in the menubar. Hit About IDLE, and there is your python version!

To verify that your pip is the version you want, all you have to do is type this:

pip -V

It will give you something like this on Windows (MAC will be similar):

pip 19.0.2 from c:\python27\lib\site-packages\pip (python 2.7)

In the case that is the incorrect path, just get get-pip.py then run it using the python version you want it to compile to like this:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py

To use the pip you wish to use, type this:

/usr/local/bin/pip install foo
xilpex
  • 3,097
  • 2
  • 14
  • 45
  • 1
    Just hit `escape` then type `:q` – xilpex Feb 21 '19 at 04:00
  • "In the case that is the incorrect path..." how would I know if that path is the correct path or the incorrect path? – uhoh Feb 21 '19 at 04:06
  • You would compare the pip to the IDLE path you desire. – xilpex Feb 21 '19 at 04:11
  • If your your desired IDLE path is 2.7 then your good to go (pip is fine)! – xilpex Feb 21 '19 at 04:13
  • The first line of `/usr/local/bin/pip` is `#!/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python` and I have just executed `pip install --upgrade PackageName` and my package was upgraded for my anaconda distribution, and not for the IDLE version. I don't think installing another `pip` should be necessary here. I have asked "How to find my IDLE's Python..." and that still seems to be undefined. – uhoh Feb 21 '19 at 04:18
  • No, I have typed that and the error includes `Requirement already up-to-date:` I believe we have not yet found the correct python. I think "How to find my IDLE's Python..." needs a more definitive answer. – uhoh Feb 21 '19 at 04:23
  • You've just re-asked my question! "How to find my IDLE's Python..." – uhoh Feb 21 '19 at 04:24
  • I updated the answer to a more efficient a reliable method to find IDLE's path, and get the version of python pip ins running on. – xilpex Feb 21 '19 at 04:30
  • Here is my about IDLE: https://i.stack.imgur.com/BDQNK.png here is my help: https://i.stack.imgur.com/N0D5H.png – uhoh Feb 21 '19 at 04:34
  • That means your IDLE version is 2.7.11 – xilpex Feb 21 '19 at 04:36
1

In the IDLE shell, enter import sys; sys.executable and you will see full path to the python that is executing IDLE.

To install to that specific executable, enter in Terminal path/to/python.exe -m pip install ....

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52
  • I've done so, I will post the results back into the question, I don't understand the message but I don't see a change. – uhoh Feb 21 '19 at 16:25