Requests is not a built in module (does not come with the default python installation), so you will have to install it:
(Requests不是内置模块(默认的python安装不附带),因此您必须安装它:)
OSX/Linux (OSX / Linux)
Use $ sudo pip install requests
(or pip3 install requests
for python3) if you have pip
installed
(使用$ sudo pip install requests
(或pip3 install requests
为python3)如果你有pip
安装)
Alternatively you can also use sudo easy_install -U requests
if you have easy_install
installed.
(另外,您也可以使用sudo easy_install -U requests
如果您有easy_install
安装。)
Alternatively you can use your systems package manager:
(另外,您可以使用系统软件包管理器:)
For centos: yum install python-requests
For Ubuntu: apt-get install python-requests
(对于centos: yum install python-requests
对于Ubuntu: apt-get install python-requests
)
Windows (视窗)
Use pip install requests
(or pip3 install requests
for python3) if you have pip
installed and Pip.exe added to the Path Environment Variable.
(如果已安装pip
并将Pip.exe添加到路径环境变量,请使用pip install requests
(或python3的pip3 install requests
)。)
Alternatively from a cmd prompt, use > Path\easy_install.exe requests
, where Path
is your Python*\Scripts
folder, if it was installed.
(或者,在cmd提示符下,使用> Path\easy_install.exe requests
,其中Path
是您的Python*\Scripts
文件夹(如果已安装)。)
(For example: C:\Python32\Scripts
) ((例如: C:\Python32\Scripts
))
If you manually want to add a library to a windows machine, you can download the compressed library, uncompress it, and then place it into the Lib\site-packages
folder of your python path.
(如果您要手动将库添加到Windows计算机,则可以下载压缩的库,解压缩,然后将其放入python路径的Lib\site-packages
文件夹中。)
(For example: C:\Python27\Lib\site-packages
) ((例如: C:\Python27\Lib\site-packages
))
From Source (Universal) (从来源(通用))
For any missing library, the source is usually available at https://pypi.python.org/pypi/ .
(对于任何缺少的库,通常可从https://pypi.python.org/pypi/获得该源。)
You can download requests here: https://pypi.python.org/pypi/requests (您可以在此处下载请求: https : //pypi.python.org/pypi/requests)
On mac osx and windows, after downloading the source zip, uncompress it and from the termiminal/cmd run python setup.py install
from the uncompressed dir.
(在Mac OS X和Windows上,下载源zip后,将其解压缩,然后从termiminal / cmd中运行python setup.py install
从未压缩的目录)。)