VS Code version: 1.12.1
Python Extension version: Jupyter 1.1.3
Python Version: Python 3.6.0 |Anaconda custom (64-bit)|
OS and version: Ubuntu 14.04 LTS
Actual behavior:
ImportError: cannot import name 'ABC'
Expected behavior
Can import class from local module
Steps to reproduce:
In data.py:
class ABC:
def init():
return
In main.py:
%% --> This is for annotating "Run cell" (or use # In [0]:)
from data import ABC
Put these files in the same directory
Run python main.py --> normal
"Run cell" in VB code using Jupyter plugin --> error
ImportError: cannot import name 'ABC'
Normally when I open the jupyter notebook in web browser, I can still do the import. It understands where the notebook is located. Maybe the plugin in VSCode should automatilly understand where the current file is located. That is, when click on "Run here", it asks "Open a new notebook", and that when it should automatically change the startupFolder.
Quote from gandhis1:
The problem is that the jupyter startup folder is the workspace root. If your project is located in a sub-directory of your workspace root, then it will not work. You either need to change your workspace root, or change the setting below:fi
"jupyter.notebook.startupFolder": "${workspaceRoot}",
--> I think this solution is not flexible to different py files opened in VS code in the same time. That is, we want to "jupyter" with some file and then "jupyter" with another file.
Copied from original issue: DonJayamanne/pythonVSCode#957
From @tamlhp on May 12, 2017 20:51
Environment data
VS Code version: 1.12.1 Python Extension version: Jupyter 1.1.3 Python Version: Python 3.6.0 |Anaconda custom (64-bit)| OS and version: Ubuntu 14.04 LTS
Actual behavior:
ImportError: cannot import name 'ABC'
Expected behavior
Can import class from local module
Steps to reproduce:
In data.py: class ABC: def init(): return
In main.py:
%% --> This is for annotating "Run cell" (or use # In [0]:)
from data import ABC
Put these files in the same directory
Run python main.py --> normal
"Run cell" in VB code using Jupyter plugin --> error ImportError: cannot import name 'ABC'
Normally when I open the jupyter notebook in web browser, I can still do the import. It understands where the notebook is located. Maybe the plugin in VSCode should automatilly understand where the current file is located. That is, when click on "Run here", it asks "Open a new notebook", and that when it should automatically change the startupFolder.
Quote from gandhis1: The problem is that the jupyter startup folder is the workspace root. If your project is located in a sub-directory of your workspace root, then it will not work. You either need to change your workspace root, or change the setting below:fi "jupyter.notebook.startupFolder": "${workspaceRoot}",
--> I think this solution is not flexible to different py files opened in VS code in the same time. That is, we want to "jupyter" with some file and then "jupyter" with another file.
Copied from original issue: DonJayamanne/pythonVSCode#957