Answer the question
In order to leave comments, you need to log in
Doesn't Run Python project via console with error ModuleNotFoundError: No module named?
Doesn't Launch Python project via console with error
from Chip88.Chip8 import *
ModuleNotFoundError: No module named 'Chip88'
If I launch via Pycharm everything starts fine.
The project tree is:
-Chip8
-chip8/Chip88
-chip8/Chip88/main.py
-chip8/Chip88/Interface.py
-chip8/Chip88/Chip8.py
-chip8/Chip88/__init__.py
-chip8/__init__.py
On startup main.py swears at the Chip8 file when the line from Chip88.Chip8 import *
How to fix?
Answer the question
In order to leave comments, you need to log in
The file you run must be in the root of the project, otherwise there is no point in the package structure you created. So the tree should look like this:
-chip8/
-chip8/chip88/
-chip8/chip88/interface.py
-chip8/chip88/chip8.py
-chip8/chip88/__init__.py
-chip8/main.py
chip8
, it contains the main file main.py
and one package chip88
. Then in the main.py file, the import from chip8.py should look like this:
By the way, this is an anti-pattern, so it's better not to do it. Import only what you intend to use in this module.
Also note that I've removed capital letters from all file and folder names. In python, it is customary to start only class names with a capital letter
***
What to read. https://chrisyeh96.github.io/2017/08/08/definitive... - about imports. Imports in python only look simple, in fact, there are important nuances that are better to understand. https://www.python.org/dev/peps/pep-0366/Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question