All modules in Python have to have a certain directory structure. You can find details here.

Create an empty file called __init__.py under the model directory, such that your directory structure would look something like that:

.
└── project
    └── src
        ├── hello-world.py
        └── model
            ├── __init__.py
            └── order.py

Also in your hello-world.py file change the import statement to the following:

from model.order import SellOrder

That should fix it

P.S.: If you are placing your model directory in some other location (not in the same directory branch), you will have to modify the python path using sys.path.

Answer from RafazZ on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › why do i get a modulenotfounderror?
r/learnpython on Reddit: Why do I get a ModuleNotFoundError?
September 2, 2021 -

Hey Guys,

I get a weird ModuleNotFoundError in one of my projects and i do not really understand why. So here is my Folder Structure:

Project\

| main.py

| packageabc\

| | __init__.py

| | abc.py

| | packagexyz\

| | | xyz.py

In every .py file is an abc/xyz or main class. Now the interesting part. Inside the abc.py I do an import like this:

from packagexyz.xyz import xyz

This works perfectly fine!

Inside the main.py I do an import like this:

from packageabc.abcimport abc

Now I get an ModuleNotFoundError. Error Code looks like this:

from packagexyz.xyz import xyz ModuleNotFoundError: no module named packagexyz.

So the import in the abc.py File that works perfectly when tested inside the file does not work if the abc.py file is imported. So why is that?

Top answer
1 of 2
2
You probably have a circular dependency - abc imports xyz and xyz imports abc. Python can't complete either import so it raises an error.
2 of 2
1
It's because of the way Python looks for modules. There's a list of paths that Python looks through to find modules, which automatically includes things like the place pip installs packages to. It also automatically includes the directory the executing script is in. It does not, however, automatically include the directory an imported module is in. So, if you're executing "abc.py" directly, in finds "packagexyz" just fine, since it knows to look in the "packageabc" folder for modules. If you are executing "main.py" instead, the only place it looks (besides the default and manually configured paths) is "Project", so it can't find packagexyz. There's really three ways you could fix this: Manually configuring paths You can keep the imports as you have them and simply ensure that the "packageabc" folder is always on the search path for modules. You can do so either by configuring the PYTHONPATH environment variable to include it or by appending it to sys.path in your "main.py" before importing abc. Absolute imports You could also change the import in "abc.py" to be relative to "Project" (from packageabc.packagexyz.xyz import xyz). Then your "main.py" would work the way it is. Of course, that in turn means you can no longer directly execute "abc.py" unless you manually configure "Project" to always be on the search path for modules. Relative imports You could also change "abc.py" to use relative imports (from .packagexyz.xyz import xyz, note the extra dot in front). Then your "main.py" would work the way it is, as well. You could also still directly execute "abc.py", but only if you make sure to do it in a way that Python is aware it is part of a larger package (otherwise, relative imports give you an error). Specifically, you'd always need to execute it like this: python -m packageabc.abc Rather than like this: python packageabc/abc.py
Discussions

Visual Studio Python Module Not Found
I'm trying to use Python in Visual Studio 2022 Community Edition. Whenever I try to import module I get this message. The modules are listed in the Solution Explorer. Can you tell me how the fix this. Traceback (most recent call last): File… More on learn.microsoft.com
🌐 learn.microsoft.com
1
1
January 14, 2023
module suddenly not found
Gracie Jensen is having issues with: I have had this happen several times using several different platforms -- I'll have imported a module into my current script and it will run jus... More on teamtreehouse.com
🌐 teamtreehouse.com
1
April 10, 2024
python - How do I troubleshoot "ModuleNotFound" errors - Stack Overflow
I often run into issues where my own modules are not found in python, and while I've been addressing them on a case-by-case basis, I don't really feel like I know how to actually troubleshoot them. It seems like such a vague error compared to anything else. More on stackoverflow.com
🌐 stackoverflow.com
Module Not Found -- Importing My Own Modules
I am running my multi-page streamlit app locally right now, and I have tried multiple approaches to solving this issue (I see others have the same issue) which is I need to import classes I created into a pages/_1_page.py. So I have tried three approaches: APPROACH 1: Use the following folder ... More on discuss.streamlit.io
🌐 discuss.streamlit.io
5
3
March 24, 2024
🌐
Python.org
discuss.python.org › python help
Module not found but it's already installed - Python Help - Discussions on Python.org
March 26, 2024 - I’m fairly new to Python. I use Python 3.11.8 (what MS Azure supports, my eventual production environment) on Windows 10. I’m testing a program on Windows 10. I have created and activated my virtual environment in the cmd.exe window. My program is in c:\users\MYUSER\onedrive - CONAME\documents\pythonprojects\CONAME\CUSTNAME\buscard\buscard.py This program worked last week just fine.
🌐
OneUptime
oneuptime.com › home › blog › how to fix 'modulenotfounderror' in python
How to Fix 'ModuleNotFoundError' in Python
January 24, 2026 - # This fails if requests is not installed import requests # ModuleNotFoundError: No module named 'requests' # Using pip pip install requests # If you have multiple Python versions pip3 install requests # Using a specific Python interpreter python3 -m pip install requests # With conda conda install requests
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-the-module-not-found-error
How to Fix The Module Not Found Error - Python
July 1, 2026 - Explanation: Python cannot find the pandas package because it is not installed in the active environment. 2. Incorrect Module Name or Spelling: Python is case-sensitive, so even a small spelling mistake can cause this error.
🌐
freeCodeCamp
freecodecamp.org › news › module-not-found-error-in-python-solved
ModuleNotFoundError: no module named Python Error [Fixed]
September 12, 2022 - Here's an example: import Numpy ... numpy and Numpy are different modules. You can fix this error by spelling the module in the right casing. In Python, you can import modules from other files using absolute or relative ...
Find elsewhere
🌐
Facebook
facebook.com › groups › pypcom › posts › 2098271270509931
How to fix 'module not found' error in Python
Logged in on your phone · Scan the QR code with your phone's camera and enter this code · JWY-YXV-MHOY · Log in to Facebook · English (UK) · Русский · Українська · Suomi · 中文(简体) · Deutsch
🌐
YouTube
youtube.com › watch
How to Fix Module Not Found Error in Python - ModuleNotFound Error (FIXED) - YouTube
In this video, I'll show you how you can fix the ModuleNotFound error in Python. The module not found error (ModuleNotFoundError) in python occurs when a spe...
Published: July 25, 2024
🌐
Real Python
realpython.com › ref › builtin-exceptions › modulenotfounderror
ModuleNotFoundError | Python’s Built-in Exceptions – Real Python
ModuleNotFoundError is a built-in exception that Python raises when an import statement fails to find a specified module.
🌐
YouTube
youtube.com › watch
FIXED: ModuleNotFoundError in Python | How to Solve Missing Module Error - YouTube
🐍 FIXED: ModuleNotFoundError in Python | Step-by-Step Solution to Missing Module Errors (Updated)Are you getting the dreaded ModuleNotFoundError in Python w...
Published: June 14, 2025
🌐
Medium
carlkho-cvk.medium.com › why-is-my-python-module-not-found-in-my-virtual-environment-779c37cd2d2c
Why is My Python Module Not Found in My Virtual Environment? | by Carl Kho | Medium
October 3, 2024 - If these paths aren’t pointing inside your virtual environment’s bin directory (e.g., ./my_venv/bin), then you’ve found the culprit! This is especially common when using tools like Homebrew (Macbook folks raise your hands 🙌), which can sometimes override your system’s default Python.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1160881 › visual-studio-python-module-not-found
Visual Studio Python Module Not Found - Microsoft Q&A
January 14, 2023 - Normally it should be installed in the default location but the Python runtime you are using might not be loading the modules from the default. If you added different versions of Python environments, please select the correct one and try to use this command py -m pip install pandas and install pandas again. Please try to create a new Python project, install the pandas and import it directly, and test to see if the pandas module can be found.
🌐
Team Treehouse
teamtreehouse.com › community › module-suddenly-not-found
module suddenly not found (Example) | Treehouse Community
April 10, 2024 - That, plus the fact that you're getting an ModuleNotFound Error, makes me believe that you may have exited the virtual environment at some point. Since dateutil should be installed in a virtual environment, exiting the environment would naturally mean that the module cannot be found.
🌐
Prakashinfotech
prakashinfotech.com › q-and-a-module-not-found-error
What does the "Module Not Found Error" in Python indicate, and how can it be resolved?
October 27, 2025 - The “Module Not Found Error” in Python occurs when the interpreter cannot find the specified module in your code.
🌐
Medium
medium.com › @ryan_forrester_ › fixing-no-module-named-errors-in-python-a-complete-guide-b989b7a2bd19
Fixing ‘No Module Named’ Errors in Python: A Complete Guide | by ryan | Medium
May 14, 2025 - When Python can’t find a module you’re trying to import, it throws a `ModuleNotFoundError`. Here’s what it looks like: Import Error: No module named 'requests' # or ModuleNotFoundError: No module named 'pandas'
🌐
Facebook
facebook.com › groups › python › posts › 1556841728489719
Why can't I install Python modules like pyautogui despite ' ...
Logged in on your phone · Scan the QR code with your phone's camera and enter this code · JWY-YXV-MHOY · Log in to Facebook · English (UK) · Русский · Українська · Suomi · 中文(简体) · Deutsch
🌐
Python
docs.python.org › 3 › builtins › exceptions.html
Built-in Exceptions — Python 3.15.2 documentation
A subclass of ImportError which is raised by import when a module could not be located. It is also raised when None is found in sys.modules.
Top answer
1 of 2
3

If you get the ModuleNotFoundError when trying to import a module of your own, then the problem is one of three things:

  1. The module is in the wrong location. Fix this error by moving it to the correct location.

  2. The import is incorrectly written to look in the wrong location. Fix this error by writing the import correctly.

  3. You expected the module search path to contain the module, but it does not. Fix this by updating the module search path, typically by adding one or more directories to sys.path or by defining a PYTHONPATH environment variable. (Usually the other two options are preferred. It's unusual that you would need to do this.)

2 of 2
1

Three potential problems that might cause it:

  1. Most times, It might be not having a src/ folder in your projects, it is advisable you do if you don't, You should also have a project dependency management system, I would recommend poetry.

  2. Secondly, python interpreter, if you use a unix machine/mac you can cd to your env/folder, where python lives -> after you run env-command to create a virtual env, it helps point installed modules to where python lives. You should also practice using full path/ as against relative import paths , which might give attempted relative import with no known parent package.

    run:

    export PYTHONPATH=${PYTHONPATH}:${env/bin/python}/
    
  3. If you don't have a main.py file in your folder and you want to run a module or file using the if __name__ == "__main__" to check if your code works, you can run this command on your terminal

    python3 -m src.module.file_name
    

NB: In most cases, if you print(__package__), you get None. That is because you don't have a parent package or a main.py file

🌐
Streamlit
discuss.streamlit.io › using streamlit
Module Not Found -- Importing My Own Modules - Using Streamlit - Streamlit
March 24, 2024 - I am running my multi-page streamlit app locally right now, and I have tried multiple approaches to solving this issue (I see others have the same issue) which is I need to import classes I created into a pages/_1_page.py. So I have tried three approaches: APPROACH 1: Use the following folder structure: |__frontend |___main.py |___util_1.py |___pages |__page.py In page.py I want to import MyClass, a class found in util_1.py.
🌐
Python.org
discuss.python.org › python help
After upgrading: "ModuleNotFoundError". How to fix? - Python Help - Discussions on Python.org
December 31, 2024 - Hello, After upgrading Python from 3.12.0 to 3.13.1, and manually editing Windows’ PATH (otherwise, it still ran the previous version)… Python can no longer find a module that was available before: ModuleNotFoundError: No module named 'ebooklib' Re-installing the modules doesn’t help, since some modules don’t install (not yet compatible with 3.13.1?): pip3 freeze --path c:\Users\joe\AppData\Local\Programs\Python\Python312\Lib\site-packages\ > python_requirements.txt pip3 install -r python_r...