Reputation: 11
I am trying to import some files from a folder. The code is rather simple:
from myproject.resources import modelselection
what I got is this
ModuleNotFoundError: No module named 'myproject'
offcourse I have the folders called my project, the subfolder resources and within that last folder I have the modelselection file which a function that I need to use.
Obviously I am quite a beginner with Python and I feel is pretty simple error (I Hope) But tricky to solve it.
Upvotes: 1
Views: 1457
Reputation: 124
Most likely forgot to add an empty __init__.py
file in each directory to make them recognised as modules
Upvotes: 0
Reputation: 5746
The issue is your current working directory. Assume the following architecture:
| folder
| |_ my project
| |_ resources.py
You can use from myproject.resources import *
only if the current working directory is folder
. You can check the current working directory with os.getcwd()
.
Upvotes: 1