如何找到我的IDLE的Python,然后将pip升级应用到它使用的包中?

问题描述 投票:3回答:2

我有两个python 2.7的兴趣:

我使用MacOS。 (我知道我已经迟到了切换到Python 3)

我想将pip install --upgrade PackageName应用到IDLE的Python使用的包中,但是当我在我的终端中键入它时,它会尝试将它应用到我的anaconda版本。

有没有办法可以找到我的IDLE的python,指向它,然后应用pip命令呢?

这就是我所拥有的:

$ 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

更新:根据this answer,我打开了IDLE并打字

import sys
sys.executable

它返回了/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

然后我打开了一个终端并进入了/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -m pip install --upgrade skyfield

我收到以下内容:

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)

我关闭IDLE然后重新打开它,然后键入

import skyfield
skyfield.__version__

而且它仍然只有1.0

没有更新。

Skyfield目前正在版本1.10 https://rhodesmill.org/skyfield/installation.html,我今天使用1.10将我的anaconda版本成功升级到pip install --upgrade skyfield

macos pip python-2.x python-idle skyfield
2个回答
1
投票

要查找您的IDLE版本,请打开IDLE,然后转到菜单栏中的help部分。点击About IDLE,还有你的python版本!

要验证您的pip是否是您想要的版本,您只需键入以下内容:

pip -V

它会在Windows上给你这样的东西(MAC会类似):

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

如果是不正确的路径,只需获取get-pip.py然后使用您希望它编译的python版本运行它,如下所示:

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

要使用您想要使用的点,请键入:

/usr/local/bin/pip install foo

1
投票

在IDLE shell中,输入import sys; sys.executable,您将看到执行IDLE的python的完整路径。

要安装到该特定可执行文件,请输入Terminal path/to/python.exe -m pip install ...

© www.soinside.com 2019 - 2024. All rights reserved.