'failed to use urllib.request with python in vscode

I tried to import urllib.request wth python in vscode but kept getting the message: ImportError: No module named request. I have no problem importing just urllib, which I know is the right line for python2. I'm sure I'm using python3 as that's what I've selected in the interpreter path.

Here's the screenshot: enter image description here

I've also put pip3 install urllib3 in the terminal and got this message which means python3 should have it:

Requirement already satisfied: urllib3 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (1.26.9)

any idea what have gone wrong or it's not the problem with python version?



Solution 1:[1]

This is related to your multiple environments. You should specify the installation path when using pip installation package.

pip install -t flodername urllib3 #the package of the python interpreter you chosen

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MingJie-MSFT