在Python2.7Windows中安装请求模块

2024-05-13 01:25:04 发布

您现在位置:Python中文网/ 问答频道 /正文

在windows上安装请求模块(python 2.7)时,我遇到了一些问题。

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

1

pip install requests

错误

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

2

easy_install requests

错误

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

3

setup.py

错误

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

任何人都可以建议如何在windows上安装这个模块,而不需要下载任何新的东西。


Tags: installorpylibdist错误setuplocation
3条回答

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

python.exe -m pip install requests

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

如注释中所述,如果已将Python添加到路径中,则只需执行以下操作:

python -m pip install requests

在windows 10上运行具有管理权限的cmd.exe 然后键入:

1)cd\Python27\脚本

2)pip安装请求

它应该有用。我的案例是Python2.7

这里有四种选择:

  1. Get ^{} set up.您创建的每个虚拟环境都将自动具有pip

  2. Get ^{} set up globally.

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

  4. 使用Christoph Gohlke's binary installers

相关问题 更多 >