PyCharm报错ModuleNotFoundError: No module named requests

The requests library has been installed, but import requests in the python file in PyCharm still report an error, the error is as follows:

Traceback (most recent call last):
  File "D:/Python Test/test.py", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

pip listShows that the requests have been installed.
Insert picture description here
(If it is not installed, you need to install the requests and commands first pip install requests)

Click File->Settings in turn to open the Settings dialog box:

Insert picture description here
Note that in the Project Interpreter, the selected python.exe is in the directory D:\Python Test\venv\Scrpts, and the path directory is the directory used to store the python test files. It is not the python installation directory, so only packages pip and setuptools will be found in this directory.
Insert picture description here
Here you need to modify it to the python installation directory . My python installation directory is in D:\Program Files (x86)\python. After modification, the installed library is displayed:

Insert picture description here

Guess you like

Origin blog.csdn.net/xp178171640/article/details/106194779