3

我有两个感兴趣的 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

更新: 根据这个答案,我打开 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,我今天成功升级了我的 anaconda 版本以1.10使用pip install --upgrade skyfield

4

2 回答 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
于 2019-02-21T03:52:18.687 回答
1

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

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

于 2019-02-21T16:20:21.937 回答