I have created a very basic package. Created a folder named my_package with mkdir, created a init.py file in this folder, and then created a my_modules.py file in the same folder.
my_modules.py has one function
def hello():
print('Hello')
I created a python script (a.py) in VS Code, put the following lines in a.py and ran a.py.
import sys
sys.path.insert(0, '/path/to/my_package')
from my_package.my_modules import hello
And now, even when I launch python3 interpreter, and import sys, and print(sys.path), I see the path to my_package in the sys.path list.
Now, script a.py runs alright and prints hello.
However,
- pylint shows a warning - Unable to resolve 'my_package.my_modules'. IntelliSense may be missing for this module.
Both pylint and intellisense are otherwise working in my VS Code setup. I have tried
- to add init-hook in .pylintrc (that did not help remove the intellisense warning)
- to setup PYTHONPATH variable.
Neither of the above were helpful in removing the intellisense warning.
Btw, when I copied the my_package directory to site-packages directory of my python 3.7 installation, then the warning went away. The copying to site-packages path appears to be a kludge as it will likely break the next time python updates.
What should I do? And I hope my question was clear. Thank you.