WaifuRanker
WaifuRanker

Reputation: 47

NameError: name 'pip' is not defined

I am unable to use the pip command. Every time I try I am met with the following error:

NameError: name 'pip' is not defined

I'm using CMD and Python 3.8. I'm almost certain that C:\python\scripts is in my path. Yet the pip command continues to elude my capabilities. I've read several articles and threads about other people who've had this problem and those solutions still fail to help me.

Copy Paste from 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

Upvotes: 3

Views: 72283

Answers (5)

Rimsha Bibi
Rimsha Bibi

Reputation: 11

I was facing the same issue in Windows. I had written 'python' and then 'pip'. Then, the error occurred that 'pip' is not defined. Then, I exited. Instead of writing 'python', I directly wrote 'pip' and it worked. And then, I installed the required package.enter image description here

enter image description here

hope this may work for others

Upvotes: 0

Igor Micev
Igor Micev

Reputation: 1652

Run

python -m ensurepip

or

python -m ensurepip --upgrade

if you have python3 rather than python installed, you may need to run this command using python3:

python3 -m ensurepip

Ref: https://docs.python.org/3/library/ensurepip.html

Upvotes: 0

darius
darius

Reputation: 29

The same error with Python 3.8 installed on Windows 7 (32-bit) last week.

Not sure how to copy error message from the console since mouse select, copy not supported within the console.

sending as answer since commenting not active

Python 3.8 and pip.exe sit in the following directories

C:\Users\a\AppData\Local\Programs\Python\Python38-32\python.exe

C:\Users\a\AppData\Local\Programs\Python\Python38-32\Scripts\pip.exe

(edited)

Just implemented select/copy/paste to Python terminal

===

--- pip

Traceback (most recent call last):

File "", line 1, in

NameError: name 'pip' is not defined


and the answer

You need to add environment variable to point to a directory including pip

Full instructions come from this site:

How to Fix PIP Is Not Recognized in Windows Command Prompt? [MiniTool Tips]

https://www.minitool.com/news/pip-is-not-recognized.html

Upvotes: -2

edfortis
edfortis

Reputation: 61

this worked for me

py -m pip install somepackage

Upvotes: 6

Red
Red

Reputation: 27557

Yes, I'm using CMD

That might be the case, but are you sure you don't have python running in it? Try entering exit() or exit, and then run your pip command.

If you are sure python is not running in youe CMD, An easy solution that may be less convenient: You can enter the command cd C:\python\scripts and then run your pip command.

Upvotes: 10

Related Questions