Import requests error in Python project

I use Robot Framework for API automation testing, because RIDE supports up to 2.8, so I installed Python 2.7.12 locally, and then installed requests, pandas, etc. libraries under Python 2, and added Python 2 scripts and lib, etc. in the environment variable Path.

But I need to view the developed Python code. Their project is developed with Python3.6, so in order to view the project in IDEA, I installed Python3.6.5, but this version is not added to the environment variable Path.

So when cmd checks the python version, only Python2 is displayed:

At this point, open the development project, and configure the Project SDK to be Python 3.6.5, and then install the library required by the project in the most common way, as follows:

After executing the command in the Python3 home directory, the requests are installed successfully. At this time, if you check the list of all installed libraries, you will find that the requests are installed successfully:

Then I happily went to Rebuild the project in the developed project. I thought that the red wavy line under the import requests statement would disappear, as a result. . . Still red! Re-bulid still doesn't work, reloading and compiling still doesn't work.

Then I thought that it might be a little trouble to install two versions of Python, so I ran to the pip installation directory of Python3 to install the requests library:

At this point, when looking at the pip list, I found that the problem was originally in the path where the command was executed:

 

Therefore, students who have installed two Python versions must pay attention to executing the install command in the path where pip is located when installing libraries under different versions.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325111967&siteId=291194637