如何在Windows上安装pip? [英] How to install pip on Windows?

查看:115
本文介绍了如何在Windows上安装pip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pip 替代了

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

推荐答案

Python 2.7.9+和3.4 +

好消息! Python 3.4 (2014年3月发布)和 Ruby Perl

Python 2.7.9+ and 3.4+

Good news! Python 3.4 (released March 2014) and Python 2.7.9 (released December 2014) ship with Pip. This is the best feature of any Python release. It makes the community's wealth of libraries accessible to everyone. Newbies are no longer excluded from using community libraries by the prohibitive difficulty of setup. In shipping with a package manager, Python joins Ruby, Node.js, Haskell, Perl, Go—almost every other contemporary language with a majority open-source community. Thank you, Python.

如果在使用Python 3.4+或Python 2.7.9+时发现没有pip,只需执行例如:

If you do find that pip is not available when using Python 3.4+ or Python 2.7.9+, simply execute e.g.:

py -3 -m ensurepip

当然,这并不意味着Python打包已解决问题.经验仍然令人沮丧.我将在堆栈溢出问题中讨论这个 Python有包/模块管理系统吗? .

Of course, that doesn't mean Python packaging is problem solved. The experience remains frustrating. I discuss this in the Stack Overflow question Does Python have a package/module management system?.

而且,对使用Python 2.7.8或更早版本(社区中相当大的一部分)的每个人来说都可惜.没有计划将Pip运送给您.遵循手动说明.

And, alas for everyone using Python 2.7.8 or earlier (a sizable portion of the community). There's no plan to ship Pip to you. Manual instructions follow.

面对它的包括电池" 的座右铭,Python出厂时没有包管理器.更糟糕的是,直到最近,Pip仍难以安装.

Flying in the face of its 'batteries included' motto, Python ships without a package manager. To make matters worse, Pip was—until recently—ironically difficult to install.

每个 https://pip. pypa.io/en/stable/installing/#do-i-need-to-install-pip :

下载 get-pip.py ,请小心将其另存为.py文件而不是.txt.然后,在命令提示符下运行它:

Download get-pip.py, being careful to save it as a .py file rather than .txt. Then, run it from the command prompt:

python get-pip.py

您可能需要管理员命令提示符才能执行此操作.按照 以管理员身份启动命令提示符 (Microsoft TechNet).

You possibly need an administrator command prompt to do this. Follow Start a Command Prompt as an Administrator (Microsoft TechNet).

这将安装pip软件包,(在Windows中)该软件包包含... \ Scripts \ pip.exe,该路径必须位于PATH环境变量中才能从命令行使用pip(请参阅替代说明"的第二部分)将其添加到您的PATH,

This installs the pip package, which (in Windows) contains ...\Scripts\pip.exe that path must be in PATH environment variable to use pip from the command line (see the second part of 'Alternative Instructions' for adding it to your PATH,

官方文档告诉用户从源代码安装Pip及其每个依赖项.对于新手来说,这是乏味的,对新手来说是非常困难的.

The official documentation tells users to install Pip and each of its dependencies from source. That's tedious for the experienced and prohibitively difficult for newbies.

为我们着想,Christoph Gohlke为流行的Python软件包准备了Windows安装程序(.msi).他为所有32位和64位Python版本构建安装程序.您需要:

For our sake, Christoph Gohlke prepares Windows installers (.msi) for popular Python packages. He builds installers for all Python versions, both 32 and 64 bit. You need to:

  1. 安装setuptools
  2. 安装pip
  1. Install setuptools
  2. Install pip

对我来说,这在C:\Python27\Scripts\pip.exe处安装了Pip.在计算机上找到pip.exe,然后将其文件夹(例如,C:\Python27\Scripts)添加到您的路径(开始/编辑"环境变量)中.现在,您应该可以从命令行运行pip了.尝试安装软件包:

For me, this installed Pip at C:\Python27\Scripts\pip.exe. Find pip.exe on your computer, then add its folder (for example, C:\Python27\Scripts) to your path (Start / Edit environment variables). Now you should be able to run pip from the command line. Try installing a package:

pip install httpie

(希望)您去了!常见问题的解决方案如下:

There you go (hopefully)! Solutions for common problems are given below:

如果您在办公室工作,则可能位于HTTP代理后面.如果是这样,请设置环境变量 http_proxyhttps_proxy .大多数Python应用程序(和其他免费软件)都遵守这些规定.语法示例:

If you work in an office, you might be behind an HTTP proxy. If so, set the environment variables http_proxy and https_proxy. Most Python applications (and other free software) respect these. Example syntax:

http://proxy_url:port
http://username:password@proxy_url:port

如果您真的很不幸,您的代理服务器可能是Microsoft NTLM 代理服务器.自由软件无法应付.唯一的解决方案是安装一个免费软件友好代理,该代理将转发到讨厌的代理. http://cntlm.sourceforge.net/

If you're really unlucky, your proxy might be a Microsoft NTLM proxy. Free software can't cope. The only solution is to install a free software friendly proxy that forwards to the nasty proxy. http://cntlm.sourceforge.net/

Python模块可以部分用C或C ++编写. Pip尝试从源代码进行编译.如果没有安装和配置C/C ++编译器,则会看到此错误消息.

Python modules can be partly written in C or C++. Pip tries to compile from source. If you don't have a C/C++ compiler installed and configured, you'll see this cryptic error message.

错误:找不到vcvarsall.bat

Error: Unable to find vcvarsall.bat

您可以通过安装C ++编译器(例如 MinGW 用于Python 2.7的Microsoft Visual C ++编译器 .

You can fix that by installing a C++ compiler such as MinGW or Visual C++. Microsoft actually ships one specifically for use with Python. Or try Microsoft Visual C++ Compiler for Python 2.7.

虽然通常更容易检查 Christoph的站点以获取您的包裹.

Often though it's easier to check Christoph's site for your package.

这篇关于如何在Windows上安装pip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆