在 python 2.7 windows 中安装请求模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18345763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 10:31:32  来源:igfitidea点击:

installing requests module in python 2.7 windows

pythonpython-2.7modulerequestinstall

提问by misguided

I am facing issues while installing request module (python 2.7) on windows.

我在 Windows 上安装请求模块(python 2.7)时遇到问题。

Tried the below steps as per documentation:

根据文档尝试了以下步骤:

1

1

pip install requests

pip install requests

error

错误

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

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

2

2

easy_install requests

easy_install requests

error

错误

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

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

3

3

setup.py

setup.py

error

错误

C:\Location\Python\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'zip_safe' warnings.warn(msg)
C:\Location\Python\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'include_package_data' warnings.warn(msg)
C:\Location\Python\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'install_requires' warnings.warn(msg)
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied

Can anyone please advise how to install the module on windows , without downloading any new stuff.

任何人都可以请教如何在 Windows 上安装该模块,而无需下载任何新东西。

采纳答案by abarnert

There are four options here:

这里有四个选项:

  1. Get virtualenvset up.Each virtual environment you create will automatically have pip.

  2. Get pipset up globally.

  3. Learn how to install Python packages manually—in most cases it's as simple as download, unzip, python setup.py install, but not always.

  4. Use Christoph Gohlke's binary installers.

  1. 开始virtualenv设置。您创建的每个虚拟环境都将自动拥有pip.

  2. 获取pip全球范围内成立。

  3. 了解如何手动安装 Python 包 - 在大多数情况下,它就像下载、解压缩、...一样简单python setup.py install,但并非总是如此。

  4. 使用Christoph Gohlke 的二进制安装程序

回答by Shire

  1. Download the source code(zip or rar package).
  2. Run the setup.py inside.
  1. 下载源代码(zip 或 rar 包)。
  2. 运行里面的setup.py。

回答by rprez

If you want to install requests directly you can use the "-m" (module) option available to python.

如果你想直接安装请求,你可以使用 python 可用的“-m”(模块)选项。

python.exe -m pip install requests

python.exe -m pip install requests

You can do this directly in PowerShell, though you may need to use the full python path (eg. C:\Python27\python.exe) instead of just python.exe.

您可以直接在 PowerShell 中执行此操作,但您可能需要使用完整的 python 路径(例如C:\Python27\python.exe),而不仅仅是python.exe.

As mentioned in the comments, if you have added Python to your path you can simply do:

如评论中所述,如果您已将 Python 添加到您的路径中,您可以简单地执行以下操作:

python -m pip install requests

python -m pip install requests

回答by Andrew Nos

On windows 10 run cmd.exe with admin rights then type :

在 Windows 10 上以管理员权限运行 cmd.exe,然后输入:

1) cd \Python27\scripts

1) cd \Python27\scripts

2) pip install requests

2)pip安装请求

It should work. My case was with python 2.7

它应该工作。我的情况是使用 python 2.7