Python Forum

Full Version: Problems with modules
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Hello :),

I'm a newbie, started messing around with python a few days ago.
I find myself sitting hours about this shit actually.
No matter what I do, almost always when I run the python script I get an ModuleNotFoundError, and it doesn't even matter what package it is.

For example I'm trying to import the PyGithub module for a small project:

when using the command python [name_of_the_script], it returns: ImportError: No module named github

when using the command python3 [name_of_the_script], it returns:

Error:
Traceback (most recent call last): File "app.py", line 3, in <module> import github File "/home/mectos/.local/lib/python3.8/site-packages/github/__init__.py", line 58, in <module> from github.MainClass import Github, GithubIntegration File "/home/mectos/.local/lib/python3.8/site-packages/github/MainClass.py", line 56, in <module> import requests File "/home/mectos/.local/lib/python3.8/site-packages/requests/__init__.py", line 112, in <module> from . import utils File "/home/mectos/.local/lib/python3.8/site-packages/requests/utils.py", line 25, in <module> from . import certs File "/home/mectos/.local/lib/python3.8/site-packages/requests/certs.py", line 15, in <module> from certifi import where ModuleNotFoundError: No module named 'certifi'
when using the command python3.8 [name_of_the_script], it returns:
Error:
Traceback (most recent call last): File "app.py", line 3, in <module> import github File "/home/mectos/.local/lib/python3.8/site-packages/github/__init__.py", line 58, in <module> from github.MainClass import Github, GithubIntegration File "/home/mectos/.local/lib/python3.8/site-packages/github/MainClass.py", line 56, in <module> import requests File "/home/mectos/.local/lib/python3.8/site-packages/requests/__init__.py", line 112, in <module> from . import utils File "/home/mectos/.local/lib/python3.8/site-packages/requests/utils.py", line 25, in <module> from . import certs File "/home/mectos/.local/lib/python3.8/site-packages/requests/certs.py", line 15, in <module> from certifi import where ModuleNotFoundError: No module named 'certifi'
important note:
The thing is, it changes the "required" package every time. The scenario is as follows:
  • I get this error about the certain module
  • I run pip3 install [package]
  • it tells me that it already exists in /usr/bin/python3.8/dist_packages -> I navigate to this directory
  • manually run sudo rm -rf [package]
  • then run again pip3 install [package]
  • it downloads it successfully
  • I try again [python/python3/python3.8] [name_of_the_script]
  • And then it returns that some another random package is missing.

I presume I have some kind of problem with my packages or PYTHONPATH or whatever?

I'm actually baffled, started with python after a few months with HTML, CSS, JS and JS's package manager npm. So things are slightly different here in Python compared to JS.

Much appreciations in advance for all the help!