Python 3.9 import issue

9.5k Views Asked by At

I just installed Python 3.9 with the Windows 64-bit installer. For some reason the all of the modules I had previously installed using pip will no longer import, unless I am running Python from the directory where they are located: C:\Users\<user>\AppData\Local\Programs\Python\Python38-32\Lib\site-packages

I tried uninstalling/reinstalling the requests module with pip and then importing requests in a shell, still not recognized.

>>> import requests
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'requests'

I imagine this is probably some environmental variable path issue. I'm new to Python, any help getting this straightened out much appreciated.

1

There are 1 best solutions below

1
On BEST ANSWER

Each version of python has its own global sites package directory where it stores the packages you install.

Ex: Python 3.8 will store under %appdata%\Local\Programs\Python\Python38-32\Lib\site-packages

Python 3.9 would store it in a different location (like Python39-32)

In order to install a package for specific version of python you need to install it with python version command.

py -3.9 -m pip install requests

You can refer the official documentation here