I am trying to import function query_creative inside of file query_creative.py into the notebook Notebook.ipynb. The file hierarchy is like this:
├───playground
│ Notebook.ipynb
├───src
├───queries
query_creative.py
The code I use in my notebook goes like this:
import sys
sys.path.append('..')
from src.query.query_creative import query_creative
and the thing works. However, the line with the function import is underlined by Pylance with the message: "Import could not be resolved" and when I use this function later on, it works but Pylance underlines it again. I've tried modifying the setting.json, but nothing seems to work. I thank in advance for any help!
For me the following fixes this: make sure you have correct python environment selected as the kernel. Then press F1, type "reload" and select "Developer: Reload Window". It will restart VSCode, reopen all your files and all imports are now detected.
Sometimes, you can select the correct kernel, close your current vscode tab tab and press Ctrl+Shift+T to reopen it, which is a little bit faster. This seems to only work if you have a workspace opened.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With