[Python3 Web crawler developed combat] 1.2.1-Requests installation

Copyright: Huawei cloud All rights reserved Please indicate the source https://blog.csdn.net/devcloud/article/details/91448228

Abstract Due Requests belong to third-party libraries, that is not the default Python library that comes with this, so we need to be installed manually. Let's first look at its installation process.

Because Requests belong to third-party libraries, that is not the default Python library that comes with this, so we need to be installed manually. Let's first look at its installation process.

1. Links

Whether it is Windows, Linux or Mac, can be installed by the package management tool pip.

Run the following command in the command line interface to complete the installation Requests library:

pip3 install requests

This is the easiest way to install, it is recommended to use this method to install.

3.wheel installation

Python is a wheel installation package that suffix .whl, in the case of poor wheel speed can choose to download the file to install, and direct pip3command with the file name can be installed.

But before that you need to install the wheel libraries, install command as follows:

pip3 install wheel

Then wheel the file to the corresponding PyPI download, such as the latest version is 2.17.3, open https://pypi.python.org/pypi/requests/2.17.3#downloads , download requests-2.17.3-py2.py3 -none-any.whl locally.

Then the command line interface into the wheel file directory, use pipcan be installed:

pip3 install requests-2.17.3-py2.py3-none-any.whl

We also completed the installation of Requests.

4. Installation source

If you do not want to use pip to install, or want to get a specific version, you can choose to download the source code installation.

This way you need to find the source address of the library, and then download and then install command.

Requests project is to address: https://github.com/kennethreitz/requests .

Git can download the source code:

git clone git://github.com/kennethreitz/requests.git

Or by curldownloading:

curl -OL https://github.com/kennethreitz/requests/tarball/master

After the download, go to the directory, execute the following command to install:

cd requests
python3 setup.py install

Requests to complete the command after the installation. This installation is troublesome because, later omitted.

5. Verify Installation

In order to verify whether the library has been successfully installed, you can test it on the command line mode:

2    $ python3>>> import requests

First input python3, enter the command line mode, and then enter the above, what if there is no error, as evidenced already successfully installed Requests.

Source: Huawei cloud community   Author: Cui Shu Jing Qing only seek

Guess you like

Origin blog.csdn.net/devcloud/article/details/91448228