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.
请先登录再写评论。
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.
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.
@Игорь Тарлинский
Could you attach a screenshot showing your project structure and the whole output of the Jupyter tool window?
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.
Hello,
I am wondering if there is a folder named "notebook" in your project structure?
Antonina Belianskaya Yes I have one! And it is indeed the source of the problem. When I rename the folder, it works. However, I am not allowed to rename the folder by my organization. How can I exclude it from whatever path it is conflicting with?
At the moment, I can rename the directory, launch jupyter, then rename it back to its original name.
Hello Lgiffon,
You may exclude the directory , please see https://www.jetbrains.com/help/pycharm/configuring-project-structure.html .
But please note that files in this folder will be excluded from indexing, search etc.