I’m opening the same python project in pycharm and everything is working well
opening same folder on vs code with same interpreter
I’m getting error ‘Unable to import’ on local modules in the project
what do i miss
Example tree
MyFile.py
│
├── csv (standard library)
├── io (standard library)
├── re (standard library)
│
|-- __init__.py
|
├── myproject.myfolder.mymodule
│ ├── methodA
│ ├── methodB
| └-- __init__.py
MyFile.py
import csv
import io
import re
from myproject.myfolder.mymodule import methodA, methodB
in pycharm it working well, in Vs-code getting unable to import exception.
Note – i tried to create workspace and venv, not working either
Thanks in advance
2
Answers
Are methodA and methodB python files? In that case you would have to do
Also make sure you run your program from the same directory as your myfile.py
You need to add init.py in the folders where you have your modules
main.py