简体   繁体   English

当我有两个版本的 python 时,如何在 PyCharm 中更新 pip?

[英]How can I update pip in PyCharm when I have two versions of python?

I have installed Python 2.7 and Python 3.5 on Windows 10. I use python 2.7 in my current PyCharm project and the project's python interpreter was set to python 2.7.我已经在 Windows 10 上安装了 Python 2.7 和 Python 3.5。我在当前的 PyCharm 项目中使用了 python 2.7,并且该项目的 python 解释器设置为 python 2.7。 Now I open PyCharm Settings and I want to update my pip of python 2.7.现在我打开 PyCharm 设置,我想更新我的 python 2.7 pip。

在此处输入图片说明

The pip version was 8.1.1 and I clicked update, expecting it to be updated to the latest version. pip 版本是 8.1.1,我点了更新,希望能更新到最新版本。 However, after it hinted "update successfully", I noticed that the version of pip was still 8.1.1.但是,在提示“更新成功”后,我注意到pip的版本仍然是8.1.1。 Then I realized that PyCharm may use my default pip version in Windows command line--which is the python3.5's pip.然后我意识到 PyCharm 可能会在 Windows 命令行中使用我的默认 pip 版本——这是 python3.5 的 pip。

How to solve this problem?如何解决这个问题呢? Is it a bug?这是一个错误吗?

To update pip on pycharm:要在 pycharm 上更新 pip:

  1. Open project settings (File > Settings...) (preferences on Mac)打开项目设置(文件 > 设置...)(Mac 上的首选项)
  2. Project > Project Interpreter项目 > 项目口译员
  3. Press the + button按 + 按钮
  4. Type "pip" in the top search box在顶部搜索框中输入“pip”
  5. In the lower right corner choose "specify version"在右下角选择“指定版本”
  6. Choose your version and press Install Package选择您的版本并按安装包

显示屏幕的图像

To upgrade any package to its latest version in PyCharm, the easiest way is to use Upgrade button.要将任何包升级到 PyCharm 中的最新版本,最简单的方法是使用升级按钮。
When any package has newer version available, it shows in "Latest" column with horizontal blue arrow.当任何包有更新版本可用时,它会显示在“最新”列中,并带有水平蓝色箭头。
Any such package can be selected and click on the Vertical arrow button on right side (as you can see in below screenshot) will upgrade that package to latest version.可以选择任何此类包,然后单击右侧的垂直箭头按钮(如下面的屏幕截图所示)将该包升级到最新版本。 在此处输入图片说明

No that is not a bug.不,这不是错误。 It's normal behavior.这是正常行为。

You can solve this by updating the pip in your Windows through cmd prompt .您可以通过cmd prompt更新 Windows 中的 pip 来解决此问题。

Either by using python:要么使用python:

python -m pip install --upgrade pip

or easy_install:或easy_install:

easy_install -U pip

In order to use the latest version of pip in newly created projects.为了在新创建的项目中使用最新版本的 pip。 You need to update Python where PyCharm references it (to find out this path, click Project Interpreter -> Base Interpreter in the project creation window).您需要更新 PyCharm 引用它的 Python(要查找此路径,请在项目创建窗口中单击Project Interpreter -> Base Interpreter )。 Then download and install or update Python to the latest version on the path specified in your IDE to the Python interpreter.然后在 IDE 中指定的 Python 解释器路径上下载并安装 Python 或将其更新到最新版本。

I don't know why it's not updating pip in your machine but I just tried to update pip in my linux environment and it worked just fine.我不知道为什么它没有在您的机器中更新 pip 但我只是尝试在我的 linux 环境中更新 pip 并且它工作得很好。

Try this.尝试这个。 Create a virtual environment within PyCharms with the interpreter of your choice, install all the packages you need and then try updating pip.使用您选择的解释器在 PyCharms 中创建一个虚拟环境,安装您需要的所有软件包,然后尝试更新 pip。 It should work now.它现在应该可以工作了。

Please check where is installed your python version that are using currently and use it to run your py commands (Note that there is a Python.exe file) like that: Python installed path - windows 7请检查您当前使用的 Python 版本的安装位置,并使用它来运行您的 py 命令(请注意,有一个 Python.exe 文件),例如: Python 安装路径 - Windows 7

When i run this command or tried to update pip using the pycharm window nothing happend当我运行此命令或尝试使用 pycharm 窗口更新 pip 时,什么也没发生

python -m pip install --upgrade pip

change to (use all the path of the python.exe as part of the command):更改为(使用 python.exe 的所有路径作为命令的一部分):

C:\Users\\AppData\Local\Programs\Python\Python.exe python -m pip install --upgrade pip

You could run this command in the bottom of pycharm where is a "Terminal" option pycharm terminal option您可以在 pycharm 的底部运行此命令,其中“终端”选项pycharm 终端选项

This worked for me.这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 pycharm python 脚本运行“pip install”? - How can i run "pip install" from a pycharm python script? 即使我下载了较新版本的 python,我似乎也没有 pip - I don't seem to have pip even when I downloaded the newer versions of python 当已经有 python 但缺少 pip 时,如何安装 pip? - How can I install pip when there is already python but pip is missed? 有2个Python版本时如何使用pip安装软件包 - How to install package using pip when you have 2 Python versions 我可以更新亚马逊旧版本的 pip 和 setuptools 吗? - Can I update Amazon's old versions of pip and setuptools? 当我的计算机上有 Python 2、Python 3 和 Anaconda 时,如何控制将包安装到哪个 Python 发行版? - How can I control which Python distribution to pip install a package to when I have Python 2, Python 3, and Anaconda on my computer? 我为Mac下载了Python,看来我有两个版本的Python? - I downloaded Python for Mac and it seems that I have two versions of Python? 如何在单个 Conda 环境中安装两个版本的 Python? - How can I install two versions of Python on a single Conda Environment? 如何处理不同 python 版本中的 pip? - How do I deal with pip in different python versions? 如果我有多个Python版本,如何将第三方库安装到特定的Python版本中? - How can I install third party libraries into the spcified Python version if I have multiple Python versions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM