microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.3k stars 294 forks source link

Notebook can't import a local package #7926

Closed chart-magnum closed 3 years ago

chart-magnum commented 3 years ago

Environment data

Expected behaviour

Jupyter notebook identifies a local package with API.

Actual behaviour

Jupyter notebook does not identify a local package with API.

Steps to reproduce:

I have two projects, one with API: magnum-api and another with notebooks: magnum-nb. Both projects are located at C:\gitlab. I would like to develop API in vs code and use it while executing notebooks. I created a workspace with both projects.

image

Following documentation and similar issues reported here, I created .env file, inside c:/gitlab/magnum-nb with the following content:

workspaceFolder=C:/gitlab/magnum-nb
PYTHONPATH=c:/gitlab/magnum-api

I also modified settings.json file to point to the .env file:

{
    "workbench.colorTheme": "Default Light+",
    "python.envFile": "${workspaceFolder}/.env",
    "jupyter.askForKernelRestart": false
}

When I open any notebook in magnum-nb project and execute

import sys
print(sys.path)

I expect to see the path to my api package: c:/gitlab/magnum-api, however, the path is not present in the path.

I guess I messed something up in the setting of .env file. Could you please kindly help me with getting the right settings.

Thanks in advance!

IanMatthewHuff commented 3 years ago

@chart-magnum Sorry quick clarification here. When you are executing that notebook, what notebook kernel (in the selector in the top right) are you using for execution?

DonJayamanne commented 3 years ago

Duplicate of https://github.com/microsoft/vscode-jupyter/issues/4593