So here is my problem. I have a personal project on Python that I was usually running on PyCharm that I preferred to then switch to VSCode. But now, I have errors on file imports that I don't understand. I don't remember having modified something around the imports, I don't exactly know if it's something to do with the IDE or if it's a global problem.
So basically on the root of my project file, I have a "utils.py" file that I made to store functions I thought I would need to use frequently over my project. At the same location (project root), there's the main .py file that I launch.
I added the path of the utils.py file to my PYTHONPATH environment variables and when I search in the variable sys.path on my Python IDLE, it does actually show me my project root path.
My main.py also manages to correctly get that import.
However, on the project root, I have a folder with Python subfiles in it which cannot access that file. So like, there's at the root main.py, utils.py and folder/subfile.py
On both main.py and the subfile.py, I added "from utils import *" to add the utils import that is recognised On the main.py, the line doesn't show any error On the subfile.py (in the folder), the line has the error "Unable to import 'utils' pylint(import-error)"
TLDR:
- I have my project root folder with utils.py, main.py, folder/subfile.py
- utils.py is on my PYTHONPATH environment variable
- the utils.py import works on main.py
- the utils.py import doesn't work on the subfile.py in the subfolder
- (I don't know if it is due to the IDE or not)