简体   繁体   English

如何从命令行获取pip工作目录

[英]How do I get pip working directory from command line

I have two python versions installed in my computer and, whenever I "pip [something]" on my command line, I would like to make sure that I am using the right pip.exe program. 我的计算机上安装了两个python版本,每当我在命令行上“ pip [something]”时,我都想确保使用的是正确的pip.exe程序。 Is there a pip command for that? 有一个pip命令吗?

Thank you. 谢谢。

pip --version

这将提供pip安装的完整路径

python has a -m module option, python-m模块选项,

$ python --help | grep -- -m
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
-m mod : run library module as a script (terminates option list)

So one can use it like, 所以可以像这样使用它

$ python -m pip install requests

And it will make sure, you are using the correct pip for the python you are running. 它将确保您为运行的python使用了正确的pip

( venv ) $ python -m pip --version
pip 19.0.3 from /home/telaverge/python/tty/tias/a/venv/local/lib/python2.7/site-packages/pip (python 2.7)
( venv ) $ deactivate
$ python -m pip --version
pip 9.0.3 from /home/telaverge/.local/lib/python2.7/site-packages (python 2.7)
$ python3 -m pip --version
pip 9.0.3 from /usr/local/lib/python3.6/site-packages (python 3.6)

Under windows, i think it is, 我认为是在Windows下

py -m pip

I am not sure if I understand the question correctly, but sorry if I am wrong! 我不确定我是否正确理解了这个问题,但是如果我错了,则对不起! If you are on Window, when installing Python, make sure to check this box(Add Python version to PATH) otherwise you will have to do it manually or probably use something like this. 如果您在Window上,则在安装Python时,请确保选中此框(将Python 版本添加到PATH),否则您将必须手动执行此操作,或者可能使用类似的方法。

python -m pip command option

在此处输入图片说明

If you have Python added to your PATH. 如果您已将Python添加到PATH。

You can do from command line(for example). 您可以从命令行执行(例如)。

pip install packagename

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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