Why am I getting "ModuleNotFoundError: No module named" Error Python Packages

1.3k views Asked by At

I am a beginner, but have some understanding and would appreciate any help.

I have am getting the ModuleNotFoundError for 2 packages; one is my own called crs_prisma and the other is the github package from pip install.

I run pip install github and it's successful. I have checked the folder in appdata\local\programs\python\python310\lib\site-packages and have confirmed the github package is there, and I am running v1.2.7. When I run pip list it also comes up github 1.2.7

When I run python --version I get Python 3.10.0 as expected. In my script I have tried importing it as both from github import Github and import github neither of which work and both give me the error:

from github import Github

ModuleNotFoundError: No module named 'github'

My other module, a class called crs_prisma is also returning the not found error. The structure is

crs_prisma

--> init.py

--> prisma

|----> init.py

|----> prisma_class.py

--> script.py

and I am trying to import the methods from that class/package using

from crs_prisma.prisma.prisma_class import *

Yet again, I receive the ModuleNotFound Error.

Note - previously, this was working. The only difference is that I uninstalled and then reinstalled Python as I had a module-caching issue, in which when I run my script, it was somehow running an old version of my class and not reflecting the changes - none of the articles online solved my issue.

Does anyone have any ideas what's going on here?

Yet when I run my script I get

1

There are 1 answers

0
UdonN00dle On

For importing your own package, the crs_prisma, you might need to define an environment variable called PYTHONPATH, and add the path to where this file is located.

For the package github, it seems that the import github statement is correct, I would recommend to reinstall it, i.e. pip uninstall github, then, perhaps try python -m pip install github, this ensures there isn't any mismatch between python and pip.