I'm using:
Python 2.7 and a virtual environment that I created using python -m virtualenv venv
I will not accept manipulating the python path as an answer
So I've been trying up and down to create a python file in my project directory that I can import but no matter what I do I keep getting the same ImportError saying there is no module with that name. Here is my file structure:
programs
|__ project
|__ __init__.py
|__ utility.py
|__ dirA
| |__ __init__.py
| |__ subdirA
| |__ venv
| |__ __init__.py
| |__ mainA.py
|__ dirB
|__ __init__.py
|__ subdirB
|__ venv
|__ __init__.py
|__ mainB.py
Inside mainA.py
these are the imports that I have tried:
from project.utility import some_function
from project.utility import *
from project import utility
import project.utility
But no matter what I do when I try to run my program using python mainA.py
I repeatedly get and ImportError saying that no module named project.utility. The ultimate goal is to be able to use utility.py
functions within any sub-directories of project
.
I've tried even doing simple examples with smaller directory structures but I cannot get it to import other files.