I am working on a Jupyter notebook on VSCod. when I import functions that I have in another local folder, VSCode does not show the docstring of the function. When I hover on the file name in the notebook, I see the message Import "scripts" could not be resolved – Pylance.
It works correctly with libraries like Numpy and Pandas and if I defined the function on the same notebook. It also works perfectly with python .py
files.
Code to reproduce where the file scripts is in some/path:
import sys
sys.path.append("some/path")
from scripts import func1
This is my settings.json file
{
"gitlens.defaultDateFormat": null,
"editor.inlineSuggest.enabled": true,
"python.defaultInterpreterPath": "~/opt/anaconda3/envs/test/bin/python",
"python.languageServer": "Pylance",
"python.analysis.autoSearchPaths": true,
"python.analysis.extraPaths": [
"./tools"
],
"editor.minimap.enabled": false,
"github.copilot.enable": {
"*": true,
"yaml": true,
"plaintext": false,
"markdown": false
}
}
2
Answers
Update
This should have been solved by this issue #3017
Old answer
After hours of searching, here is the solution per this comment. Just disable the Pylance LSP Notebooks experiment by adding the following to the
settings.json
file for user:and this in the workspace
settings.json
file just to include your local module.If you use the same local path frequently in your project and you are using a conda environment, there is a better way to solve this issue. Plus, avoiding adding the lines
sys.path.append(..)
. You can run the commandconda develop path/to/local/module
and it will add this path to the libraries of this environment.I have the same trouble but the solution proposed does not work completely for me… It shows only
`(function) siges_seine: ((mailleId: int) -> DataFrame) | Any“
but not the docstring I have written.