简体   繁体   中英

Why wont pip work outside of PyCharm

I think I may have screwed myself.

I had pip working in my venv in PyCharm fine

but whenever I try to accsses pip from the powershell or cmd line, it doesn't recognize the command. I double checked the path variables and everything, and now further discouraged as the GUI platform I was working with wont open in the venv.

What are my options here? I need to get pip working in the powershell, it says it's there when I upgrade it, but says its missing when I try to use it, which is unbelievably frustrating. tried also uninstalling pip from the venv but that didn't help anything either. Any help is greatly appreciated.

when I try to install pip normally, i get this

PS C:\\Users\\lerug\\Downloads> py .\\get-pip.py Requirement already up-to-date: pip in c:\\users\\lerug\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages PS C:\\Users\\lerug\\Downloads>

PyCharm is a nice IDE because when you set up a project you can configure your local interpreter ( python.exe ) and it will remember. The Windows command prompt defaults to your environmental settings unless you tell it explicitly the path of the pip/python you want - which will always be in the Scripts folder of your virtualenv.

So for instance, to use the virtualenv version of pip you can path to your environment and type Scripts\\python -m pip install <package> (noting that I have had trouble using Scripts\\pip install <package> directly before; but given that the former has always worked, I haven't bothered to figure out why). Similarly, you can use the virtualenv python interpreter on the command line simply by typing Scripts\\python .

You DON'T want to change your environmental settings to point to your virtualenv .exe because things can get pretty messed up that way. It also negates the point of keeping your python environments isolated.

As an aside - usually people interact with a virtualenv by "activating" it. This is optional and just puts everything relative to the Scripts folder (so you don't have to keep typing Scripts\\ in front). The other benefit is that you can start pathing around to other directories and the command line will remember (while it is activated) that you want to use those particular versions of pip and python. If you're using the command line you can activate with Scripts\\activate . If you're using PowerShell you'll need to use Scripts\\activate.ps1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM