Jupyter Notebook Breaks in Pycharm

I'm running the professional version 20.2.3 on Ubuntu 20 and I just cannot get Jupyter notebooks to run correctly within the IDE. When i try to run any notebook cell I just get the following:

/home/user/.virtualenvs/aima-python/bin/jupyter notebook --no-browser
Traceback (most recent call last):
File "/home/user/.virtualenvs/aima-python/bin/jupyter-notebook", line 5, in <module>
from notebook.notebookapp import main
ModuleNotFoundError: No module named 'notebook.notebookapp'; 'notebook' is not a package

The notebook module is in fact in the venv path on disk and so is the notebookapp.py file within the notebook module. 

If I run jupyter from that venv outside of Pycharm, it runs just fine and no problem. I can even run the notebook from within Pycharm's terminal for the project and it works. But the moment I try and run this in the IDE by clicking the gutter run buttons it breaks and produces the above error which kind of defeats the purpose of the IDE. I can use Vim and my browser, but I didn't pay for those.

5 comments
Comment actions Permalink

After playing around more I see what is happening. This is a git project which I created a virtual env for and there is confusion about what is sitting where when pycharm tries to look for imports. I don't know what the fix is and I just switched to a vim and browser setup because I can't waste time on this anymore.

1
Comment actions Permalink

I have the same issue on `OS X 10.14.5` and `PyCharm Professional 2020.3.3`.

Creating virtual environment in local directory with correctly installed `pip install jupyter` inside it - outputs the same error.

Launching from the command line gives no problem.

Traceback (most recent call last):
File "/Users/justatom/Project/justatom/env/bin/jupyter-notebook", line 5, in <module>
from notebook.notebookapp import main
ModuleNotFoundError: No module named 'notebook.notebookapp'
0
Comment actions Permalink

@Игорь Тарлинский

Could you attach a screenshot showing your project structure and the whole output of the Jupyter tool window?

0
Comment actions Permalink

I have the same issue. Virtualenv works fine with jupyter and jupyter-notebook, but my guess is Pycharm is executing it inside some strange environment that is breaking the virtualenv.

0
Comment actions Permalink

Hello, 

 

I am wondering if there is a folder named "notebook" in your project structure? 

0

Please sign in to leave a comment.