This is roughly my relevant folder structure:
renny
|
|____ app
|____ __init__.py
|____ chatbox.py
|
|____ utils
|____ __init__.py
|____ wids.py
|
|____ main.py
The main.py
imports the chatbox.py
script, and the chatbox.py
script imports the wids.py
script.
When I run the main.py
I get no issues, but I can't run the chatbox.py
script directly, I get
ModuleNotFoundError: No module named 'utils'
I assume it's because it is in a folder up, but it shouldn't be a problem since all folders have the __init__.py
file.
Furthermore, I tried moving the utils folder to the app folder, but now I get the same problem when I run the main.py
file. It makes sense since it's not in the same folder anymore, but it shouldn't do that.
I tried reopening VSCode, I tried from another computer, I tried with or without virtual enviroment, I tried restructuring the entire folder.
I think it should work right away, but I read somewhere that I should create a setup.py
, which I'm not very familiar with, or that I should install the dependencies as a separate package, or that I should add the utils folder to the path. I understand I should learn how to do the setup.py
thingy, but it's a really small project and I don't think I should create an installable python package just for a little function. It is really my first project and I want to understand why it doesn't work as it should.
Also, I verified "sys.path" and it only includes these:
['c:\\Benaj\\Desktop\\renny\\app',
'C:\\Users\\Benaj\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
'C:\\Users\\Benaj\\AppData\\Local\\Programs\\Python\\Python310\\DLLs',
'C:\\Users\\Benaj\\AppData\\Local\\Programs\\Python\\Python310\\lib',
'C:\\Users\\Benaj\\AppData\\Local\\Programs\\Python\\Python310',
'c:\\Benaj\\Desktop\\renny\\env',
'c:\\Benaj\\Desktop\\renny\\env\\lib\\site-packages']
Should it include the utils folder?