Import Requests Module Not Found into venv

23 views Asked by At

I was able to import requests and write a quick query in my root directory to successfully return some JSON from a rest endpoint. Then I learned I should be doing this in a virutal environment, so I created one but when I try to import requests to a virtual environment, I just keep getting module not found. I can see it "lib" folder of my project.

I've done a ton of reading on this and at the moment think that it has something to do with me originially installing "requests" in my root directory. I've tried adding the below line to settings.json but no luck.

{"python.analysis.extraPaths": C:\Users\Tom\OneDrive\Documents\Projects\venv\oraiV\Scripts}

C:\Users\Tom\OneDrive\Documents\Projects\venv\oraiV>pip --version
pip 24.0 from C:\Users\Tom\AppData\Roaming\Python\Python39\site-packages\pip (python 3.9)

C:\Users\Tom\OneDrive\Documents\Projects\venv\oraiV>python --version
Python 3.9.9

What I noticed is that when i do a >pip list, the version of "requests" does not match the version installed in my virtual environment. It matches the version in the global directory. What's odd is that I was able to import pyodbc without any issue. Requests have been giving me trouble since the start.

Is my theory correct? Is it looking for the wrong version of requests?
global vs venv

C:\Users\Tom\OneDrive\Documents\Projects\venv\oraiV>pip list
Package                Version
---------------------- ---------
asttokens              2.2.1
backcall               0.2.0
base58                 2.1.1
bech32                 1.2.0
boto3                  1.26.74
botocore               1.29.74
certifi                2022.12.7
cffi                   1.15.1
charset-normalizer     3.0.1
colorama               0.4.6
comm                   0.1.2
debugpy                1.6.6
decorator              5.1.1
et-xmlfile             1.1.0
executing              1.2.0
idna                   3.4
importlib-metadata     6.0.0
ipykernel              6.21.2
ipython                8.10.0
isort                  5.12.0
jedi                   0.18.2
jmespath               1.0.1
jupyter_client         8.0.3
jupyter_core           5.2.0
matplotlib-inline      0.1.6
mock                   5.0.1
msgpack                1.0.4
mysql-connector-python 8.0.33
nest-asyncio           1.5.6
numpy                  1.24.2
openpyxl               3.1.1
packaging              23.0
pandas                 1.5.3
parso                  0.8.3
pickleshare            0.7.5
pip                    24.0
platformdirs           3.0.0
prompt-toolkit         3.0.37
psutil                 5.9.4
pure-eval              0.2.2
py-algorand-sdk        2.0.0
pycodestyle            2.10.0
pycparser              2.21
pycryptodomex          3.17
Pygments               2.14.0
PyNaCl                 1.5.0
pyodbc                 5.1.0
pysha3                 1.0.2
python-dateutil        2.8.2
pytz                   2022.7.1
pywin32                305
PyYAML                 6.0
pyzmq                  25.0.0
# **requests               2.28.2**
s3transfer             0.6.0
setuptools             58.1.0
six                    1.16.0
stack-data             0.6.2
tabulate               0.9.0
tornado                6.2
traitlets              5.9.0
urllib3                1.26.14
wcwidth                0.2.6
zipp                   3.14.0

I've tried adding another path to settings.json {"python.analysis.extraPaths": C:\Users\Tom\OneDrive\Documents\Projects\venv\oraiV\Scripts}

Was expecting to import requests and be able to run my project. Instead I get the below error:

NameError: name 'requests' is not defined

pylance error

0

There are 0 answers