python如何使用pip命令,如何从CMD运行Pip命令

As I understand, Python 2.7.9 comes with Pip installed, however when I try to execute a Pip command from CMD (Windows) I get the following error:

'pip' is not recognized as an internal or external command, operable program or batch file.

When I type python I do get the following, which suggests it has been installed correctly:

Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

I did however need to add some environmental variables to get the python part working on CMD:

Add to the environment variable PATH: "C:\Python27\"

Define the system variable PYTHONPATH: "C:\Python27\"

I cannot find a Pip folder within the Python directory, however there is a folder called "ensurepip" in C:\Python27\Lib\.

Does anybody know how can I get Pip commands to start working in CMD?

解决方案

Little side note for anyone new to Python who didn't figure it out by theirself: this should be automatic when installing Python, but just in case, note that to run Python using the python command in Windows' CMD you must first add it to the PATH environment variable, as explained

To execute Pip, first of all make sure you have it. So type in your CMD:

> python

>>> import pip

>>>

And it should proceed with no error. Otherwise, if this fails, you can look here to see how to install it. Now that you are sure you've got Pip, you can run it from CMD with Python using the -m (module) parameter, like this:

> python -m pip

Where is any Pip command you want to run, and are its relative arguments, separated by spaces.

For example, to install a package:

> python -m pip install

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值