A brief discussion on the import of requests module in python

不言
Release: 2018-06-04 17:53:59
Original
3800 people have browsed it

Today, the editor will share with you an article about the import of the requests module in python. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor and take a look.

Today when using Pycharm to capture web page images, you need to import the requests module, but an error is reported when importing requests in pycharm.

Cause: The requests library has not been installed in python

##Solution:

1. First find pip in your python installation directory

2. Open the cmd window on your computer.

First click on the start bar, enter cmd in the search bar, and press Enter to open the cmd window. Change the directory in cmd to the path where your pip is located.

For example, mine is in the directory C:\Python27\Scripts. First switch to the d drive and then enter this path.

Specific command: cd..Press Enter cd..Press Enter to the C drive, then cd space C:\Python27\Scripts and press Enter, thus entering the pip path.

#3. At this time, I found a bunch of red words on the cmd command line, and an error was reported during installation. The reason is that the path C:\Python27\Scripts is not configured. in the PATH environment variable. Next we configure environment variables.

Click My Computer, Properties, then Advanced System Settings, Environment Variables, and then add the C:\Python27\Scripts path to the variable value.

4. Then enter the command pip install requests to perform the installation and wait for it to complete.

#5. In this way, no error will be reported when importing the requests library.

Related recommendations:

How to import oracle data in Python

The above is the detailed content of A brief discussion on the import of requests module in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template