Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run pip on python for windows? [duplicate]

I've just installed python 3.5, ran Python 3.5 (32-bit) and typed

pip 

and received the message:

Traceback (most recent call last):   File "<pyshell#2>", line 1, in <module>     pip NameError: name 'pip' is not defined 

I don't see any scripts directories in my path, but I found pip.py in C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\Scripts.

I selected the option to "Add python to environment variables" during installation, but it doesn't seem to have done anything.

I googled this and got this guide, which says that earlier versions need to add some path names. I don't have a C:\Python... directory so I tried adding the Scripts folder from above, same result.

How do I install python so that it actually works (ie. I can run pip, install modules, etc.)?

like image 755
quant Avatar asked Oct 18 '15 01:10

quant


People also ask

How do I run a pip command in Python?

Ensure you can run pip from the command lineRun python get-pip.py . 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they're not installed already. Be cautious if you're using a Python install that's managed by your operating system or another package manager.

Where is pip installed on Windows?

If PIP is installed correctly, we will see a message indicating the version of PIP and its location on the local system, like the following: pip 22.0. 2 from C:\Users\Utente\AppData\Local\Programs\Python\Python310\lib\site-packages\pip (python 3.10) .

Can I install two versions of a Python package on the same computer?

With maven or gradle you can install two versions of the same package, with pip you cant. Still you cant use two versions of the same package in the same program.


2 Answers

Maybe you'd like try run pip in Python shell like this:

>>> import pip >>> pip.main(['install', 'requests']) 

This will install requests package using pip.


Because pip is a module in standard library, but it isn't a built-in function(or module), so you need import it.

Other way, you should run pip in system shell(cmd. If pip is in path).

like image 164
Remi Crystal Avatar answered Sep 19 '22 16:09

Remi Crystal


I have a Mac, but luckily this should work the same way:

pip is a command-line thing. You don't run it in python.

For example, on my Mac, I just say:

$pip install somelib

pretty easy!

like image 45
Eli Dinkelspiel Avatar answered Sep 20 '22 16:09

Eli Dinkelspiel