Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notebook can't import a local package #7926

Closed
chart-magnum opened this issue Oct 14, 2021 · 2 comments
Closed

Notebook can't import a local package #7926

chart-magnum opened this issue Oct 14, 2021 · 2 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@chart-magnum
Copy link

chart-magnum commented Oct 14, 2021

Environment data

  • VS Code version: XXX
  • Jupyter Extension version (available under the Extensions sidebar): v2021.9.1001312534
  • Python Extension version (available under the Extensions sidebar): v2021.10.1336267007
  • OS (Windows | Mac | Linux distro) and version: Windows 10
  • Python and/or Anaconda version: Python3.8
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N.A
  • Jupyter server running: Local | Remote | Local

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!

@chart-magnum chart-magnum added the bug Issue identified by VS Code Team member as probable bug label Oct 14, 2021
@IanMatthewHuff
Copy link
Member

@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
Copy link
Contributor

Duplicate of #4593

@DonJayamanne DonJayamanne marked this as a duplicate of #4593 Oct 14, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants