【问题标题】:My pip isn't working, for both versions of python对于两个版本的 python,我的 pip 都不起作用
【发布时间】:2020-10-03 06:45:38
【问题描述】:

所以我已经在 cmd 中安装了 python 2.7 和 python 3.8,但如果我输入以下之一:

点安装

pip --version

它使用 python 2.7 版本。我不认为我可以使用随 python 3 安装的软件包。 我试过了:

  • 重新安装 python (2 & 3)

  • 将它添加到我的路径

  • 更改保存目录

  • Pip3 命令

  • 引导点

但没有一个有效。(我也在 windows 7 上,并且需要 pip 和 python 用于 2.7 和 3.8)

当我使用时:

python3 -m pip install x

py -3 -m pip install x

它提出了:

导入 pyexpat 时 DLL 加载失败:指定的模块可以 找不到

【问题讨论】:

  • 什么不起作用?你有错误信息吗?

标签: python-3.x python-2.7 pip


【解决方案1】:

Windows 中的 Python 3 命令是 python3。因此,如果您想使用 python 3 运行 pip,您必须执行 python3 -m pip install

您还可以将Path variable 中的 Python 2 路径替换为 Python 3 路径,这样当您运行 python 命令时,它将直接使用 Python 3。

希望我有用。

【讨论】:

    【解决方案2】:

    看看官方文档,

    https://docs.python.org/3/installing/index.html?highlight=pip#work-with-multiple-versions-of-python-installed-in-parallel

    如果你在windows上,你可以使用,

    py -2   -m pip install SomePackage  # default Python 2
    py -2.7 -m pip install SomePackage  # specifically Python 2.7
    py -3   -m pip install SomePackage  # default Python 3
    py -3.4 -m pip install SomePackage  # specifically Python 3.4
    

    在 Linux、Mac OS X 和其他 POSIX 系统上,使用版本化的 Python 命令和 -m 开关来运行适当的 pip 副本:

    python2   -m pip install SomePackage  # default Python 2
    python2.7 -m pip install SomePackage  # specifically Python 2.7
    python3   -m pip install SomePackage  # default Python 3
    python3.4 -m pip install SomePackage  # specifically Python 3.4
    

    希望这会有所帮助!

    【讨论】:

      【解决方案3】:

      如果您同时安装了versionspython,则只需输入pip 命令即可运行python pip,其path 排在第一位。您可以使用pip3 对应于python3 的pip 和pip2 对应于python2 的pip。但推荐的方法是:

      对于 Python 3

      py -3 -m pip install
      

      对于 Python 2

      py -2 -m pip install
      

      【讨论】:

      • 它出现:DLL load failed while importing pyexpat: the specified module could not be found
      • 显然Python 3.8windows 存在问题。卸载它并尝试安装Python 3.7。如需进一步阅读,您可以查看github.com/psycopg/psycopg2/issues/990
      猜你喜欢
      • 2022-06-24
      • 1970-01-01
      • 1970-01-01
      • 2021-08-03
      • 1970-01-01
      • 2021-11-23
      • 2013-07-10
      • 2017-05-23
      • 2023-03-12
      相关资源
      最近更新 更多