NameError:名称“pip”未定义

Wai*_*ker 3 python pip python-3.x

我无法使用 pip 命令。每次我尝试时都会遇到以下错误:

NameError: name 'pip' is not defined
Run Code Online (Sandbox Code Playgroud)

我正在使用 CMD 和 Python 3.8。我几乎可以肯定那C:\python\scripts是我的道路。然而 pip 命令仍然无法满足我的能力。我读过几篇关于其他遇到此问题的人的文章和主题,但这些解决方案仍然无法帮助我。

从 CMD 复制粘贴:

C:\Windows\System32>py

Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> pip

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'pip' is not defined
Run Code Online (Sandbox Code Playgroud)

Ann*_*Zen 8

是的,我正在使用 CMD

可能是这样,但是你确定你没有在其中运行 python 吗?尝试输入exit()exit,然后运行 ​​pip 命令。

如果您确定 python 没有在您的 CMD 中运行,一个简单的解决方案可能不太方便:您可以输入命令cd C:\python\scripts,然后运行 ​​pip 命令。


edf*_*tis 5

这对我有用

py -m pip 安装某个包