【问题标题】:pip install, How to fix ImportErrorpip install, 如何修复 ImportError
【发布时间】:2021-12-23 04:04:14
【问题描述】:

我在尝试使用pip install 时收到ImportError: cannot import name 'Literal' from 'typing' 错误消息。有人可以帮忙吗?

【问题讨论】:

  • 您使用哪个 Python 版本? typing.Literal 可从 Python 3.8 获得。
  • 您好,欢迎您。可能是您的 python 和 pip 版本已过时。正如@balrundev 所说,您可能需要将其更新到 Python 3.8 或更高版本。
  • 我使用的是 3.9.0
  • 你安装了多个python版本吗?
  • 是的,2.7、3.8.0 和 3.9.0

标签: python shell command-line command


【解决方案1】:

问题在于您的环境变量的配置。首先,我建议你卸载所有未使用的 python 版本。在我看来,最新的python 3.x.x系列是最好的。

步骤:

访问它的最简单方法是在 Windows 10 搜索栏中键入 environment variable。 (假设您使用的是 Windows 10)

然后按照这些:

在后续窗口的下半部分搜索path

如果你双击它,寻找 python。确保在此处添加了此类路径,并且您需要具有兼容版本的 python。通常,您的 python bin 目录位于 Program Files 中。

【讨论】:

  • 哇,我很笨。我真的有一个 python 2.7,另一个是 3.9。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-14
  • 2020-12-16
  • 2021-08-16
  • 1970-01-01
  • 2019-05-27
  • 2021-09-29
相关资源
最近更新 更多