代码之家  ›  专栏  ›  技术社区  ›  uhoh Jacob

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

  •  1
  • uhoh Jacob  · 技术社区  · 6 年前

    我有两个感兴趣的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 我打开了闲置的文件并打字

    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)
    

    我关闭空闲,然后重新打开,然后键入

    import skyfield
    skyfield.__version__
    

    但仍然只是 1.0

    没有更新。

    Skyfield当前处于版本 1.10 https://rhodesmill.org/skyfield/installation.html 我今天成功地将我的水蟒版本升级到 1.10 使用 pip install --upgrade skyfield

    0 回复  |  直到 6 年前
        1
  •  1
  •   xilpex    6 年前

    要查找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
    

    要使用您希望使用的pip,请键入以下内容:

    /usr/local/bin/pip install foo
    
        2
  •  1
  •   Terry Jan Reedy    6 年前

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

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