Note: this problem seems to be a VSCode specific issue as I can run it outside of VSCode and it seems to work. I want to get it working inside VSCode so I can debug it.
I have a virtualenv that I setup to isolate packages installed from the main system (for setup/testing purposes). I’m having issues where I’m trying to install packages but it doesn’t seem to want to find my module.
The code can be reproduced on my end with a single line of code (because the problem is that stupid):
import requests
I’m getting the following error when running “python3 test.py” (using python 3.10, to be clear):
ModuleNotFoundError: No module named 'requests'
Oddly enough, when I type “sudo python3 test.py”, it runs fine. This, to me, says whatever packages I’m installing are being installed into the wrong location or something to that effect. That said, I can see the package just fine.
I have tried the following:
pip3 install requests
apt-get install python3-requests
I have also tried both of those using sudo, to see if that makes a difference (it doesn’t).
I tried “pip3 list” and got the following:
`Package Version
certifi 2024.2.2
charset-normalizer 3.3.2
idna 3.7
pip 23.0.1
python-dateutil 2.9.0.post0
requests 2.31.0
setuptools 66.1.1
six 1.16.0
urllib3 2.2.1
wheel 0.38.4`
I can see requests is installed, sudo can see requests installed, running it with just python3 (no sudo) can’t seem to figure it out (at least not in VSCode). Any ideas what might be going on?
Thanks!