How do I install pip on Windows?

2018-12-30 23:06发布

pip is a replacement for easy_install. But should I install pip using easy_install on Windows? Is there a better way?

30条回答
弹指情弦暗扣
2楼-- · 2018-12-30 23:11

Installers

I've built Windows installers for both distribute and pip here (the goal being to use pip without having to either bootstrap with easy_install or save and run Python scripts):

On Windows, simply download and install first distribute, then pip from the above links. The distribute link above does contain stub .exe installers, and these are currently 32-bit only. I haven't tested the effect on 64-bit Windows.

Building on Windows

The process to redo this for new versions is not difficult, and I've included it here for reference.

Building distribute

In order to get the stub .exe files, you need to have a Visual C++ compiler (it is apparently compilable with MinGW as well)

hg clone https://bitbucket.org/tarek/distribute
cd distribute
hg checkout 0.6.27
rem optionally, comment out tag_build and tag_svn_revision in setup.cfg
msvc-build-launcher.cmd
python setup.py bdist_win32
cd ..
echo build is in distribute\dist

Building pip

git clone https://github.com/pypa/pip.git
cd pip
git checkout 1.1
python setup.py bdist_win32
cd ..
echo build is in pip\dist
查看更多
何处买醉
3楼-- · 2018-12-30 23:11

PythonXY comes with pip included, among others.

查看更多
君临天下
4楼-- · 2018-12-30 23:12

Updated at 2016 : Pip should already be included in Python 2.7.9+ or 3.4+, but if for whatever reason it is not there, you can use the following one-liner.

PS:

  1. This should already be satisfied in most cases but, if necessary, be sure that your environment variable PATH includes Python's folders (for example, Python 2.7.x on Windows default install: C:\Python27 and C:\Python27\Scripts, for Python 3.3x: C:\Python33 and C:\Python33\Scripts, etc)

  2. I encounter same problem and then found such perhaps easiest way (one liner!) mentioned on official website here: http://www.pip-installer.org/en/latest/installing.html

Can't believe there are so many lengthy (perhaps outdated?) answers out there. Feeling thankful to them but, please up-vote this short answer to help more new comers!

查看更多
永恒的永恒
5楼-- · 2018-12-30 23:12

I think the question makes it seem like the answer is simpler than it really is. Running of pip will sometimes require native compilation of a module (64-bit Numpy is a common example of that). In order for pip's compilation to succeed, you need Python which was compiled with the same version of MSVC as the one pip is using. Standard Python distributions are compiled with MSVC 2008. You can install an Express version of VC2008, but it is not maintained. Your best bet is to get an express version of a later MSVC and compile Python. Then PIP and Python will be using the same MSVC version.

查看更多
爱死公子算了
6楼-- · 2018-12-30 23:14

Python 3.4, which was released in March 2014, comes with pip included:
http://docs.python.org/3.4/whatsnew/3.4.html
So since the release of Python 3.4, the up-to-date way to install pip on Windows is to just install Python. When sticking to all defaults during installation, pip will be installed to
C:\Python34\Scripts\pip3.exe.

查看更多
初与友歌
7楼-- · 2018-12-30 23:15

How to install pip:

  1. Download and install ActivePython
  2. Open a command prompt (CMD)
  3. Type pypm install pip
查看更多
登录 后发表回答