[Solved] ModuleNotFoundError: No module named ‘requests‘

environment

MacOS 11.4
has been implemented:

pip3 install requests

It’s still wrong.

This reminds me that there are two PIP3

report errors:

import requests
ModuleNotFoundError: No module named ‘requests’

terms of settlement

Execute the following code

/Library/Frameworks/Python.framework/Versions/3.9/bin/pip3 install requests

It was solved successfully.

Cause analysis:
there are two versions of python3 on my computer. I guess one comes with the system. One is that I use brew to install it automatically due to dependency.

The environment variable is /usr/local/opt/ [email protected]/bin/pip3 script is executed in /Library/Frameworks/Python.framework/Versions/3.9/bin/pip3.

The following test shows that my python3 and PIP3 paths do not match.

itkey@ycmit: ~ $ which python3                                                                           [16:43:26]
/usr/local/bin/python3
itkey@ycmit: ~ $ ls -all /usr/local/bin/python3                                                          [16:43:29]
lrwxr-xr-x  1 itkey  admin  69 12 22  2020 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.9/bin/python3
itkey@ycmit: ~ $ which pip3                                                                              [16:43:32]
/usr/local/bin/pip3
itkey@ycmit: ~ $ ls -all /usr/local/bin/pip3                                                             [16:43:54]
lrwxr-xr-x  1 itkey  admin  35  4 24 08:25 /usr/local/bin/pip3 -> ../Cellar/[email protected]/3.9.4/bin/pip3

cut the weeds and dig up the roots

Now that the above reason analysis has shown that python3 and PIP3 in my path do not match, just modify them to match.

Put brew before the environment variable

#python3 Use brew
export PATH="/usr/local/Cellar/[email protected]/3.9.4/bin:$PATH"

Read More: