I looked up a lot of threads but none solved my issue
I have the following dir in my project
my_proj
folder_one
__init__.py
file_one.py
folder_two
__init__.py
file_two.py
__init__.py
main.py
I am trying to import from file_two.py the FileTwo class:
file_one.py:
from folder_two.file_two import FileTwo
But i get the following error when I try to run the file_one.py file:
ModuleNotFoundError: No module named 'folder_two'
I tried the following:
- Adding
PYTHONPATHto .env file - Adding
"python.envFile": "${workspaceFolder}/.env"to settings.json - Adding
"terminal.integrated.env.osx"to settings.json - Adding
"python.analysis.extraPaths"to settings.json - Adding
"python.autoComplete.extraPaths"to settings.json - Adding
__init__.pyto every folder exists in my project
When I print the sys.path from file_one.py I get the path: /my_proj/folder_one instead of /my_proj
How can I add the /my_proj root directory of my project to sys.path (not permanently) so I could run any python file in my project and still access all files?