简体   繁体   English

Pycharm jupyter notebook wsl:未安装 Jupyter 包

[英]Pycharm jupyter notebook wsl: Jupyter package is not installed

I would like to use Jupyter notebook inside Pycharm.我想在 Pycharm 中使用 Jupyter notebook。 The project interpreter is a python2.7 from a virtual environment inside WSL (ubuntu 18.04).项目解释器是来自 WSL (ubuntu 18.04) 内部虚拟环境的 python2.7。

The Jupiter package is correctly installed inside the virtual environment (I can run it by jupyter notebook ). Jupiter 包已正确安装在虚拟环境中(我可以通过jupyter notebook运行它)。

My problem is that when I want to use Jupyter notebook inside Pycharm, I get the following error: Run Error Jupyter package is not installed (see picture).我的问题是,当我想在 Pycharm 中使用 Jupyter notebook 时,出现以下错误: Run Error Jupyter package is not installed (见图)。

在此处输入图片说明

Any idea what's going on here?知道这里发生了什么吗?

I had this problem in Python 3. Below are the steps I took to resolve the issue;我在 Python 3 中遇到了这个问题。以下是我为解决这个问题所采取的步骤; I believe they should resolve the issue for you too:我相信他们也应该为你解决这个问题:

  1. I had Jupyter Lab installed.我安装了 Jupyter Lab。 Pycharm only works with Jupyter Notebook. Pycharm 仅适用于 Jupyter Notebook。 Long story short, if you have Jupyter Lab installed you need to uninstall all your packages using:长话短说,如果您安装了 Jupyter Lab,则需要使用以下命令卸载所有软件包:

    $ pip freeze | $ pip 冻结| xargs pip uninstall -y xargs pip 卸载 -y

  2. Restart your computer重启你的电脑

  3. Follow Jupyter Notebook installation instructions按照Jupyter Notebook 安装说明进行操作

  4. Make sure WSL is set up through pycharm instructions: wsl pycharm instructions确保通过 pycharm 指令设置 WSL: wsl pycharm 指令

  5. In Pycharm, open an .ipynb file.在 Pycharm 中,打开一个 .ipynb 文件。 Click the dropdown that says "Managed Jupyter server" It's right above the text editor.单击文本编辑器正上方的“Managed Jupyter server”下拉菜单。 Select "configure Jupyter server".选择“配置 Jupyter 服务器”。 Check configured server.检查配置的服务器。

  6. In your wsl terminal, type jupyter notebook.在您的 wsl 终端中,输入 jupyter notebook。 Copy and paste the text that looks like: http://localhost:8888/?token=874asdf687asd6fasd8f74ds6f4s9d8f7sddf into the cofigured server box in Pycharm.将类似于以下内容的文本复制并粘贴: http://localhost:8888/?token=874asdf687asd6fasd8f74ds6f4s9d8f7sddfPycharm的配置服务器框中。

That's it.就是这样。 You should be able to run the jupyter cells in pycharm now.您现在应该能够在 pycharm 中运行 jupyter 单元格。

I have Pycharm 2020.3 For me the issue was I was using a virtual environment with "inherit global site packages."我有 Pycharm 2020.3 对我来说,问题是我使用的是带有“继承全局站点包”的虚拟环境。 I had Jupyter installed in global site packages but NOT the virtual environment.我在全局站点包中安装了 Jupyter,但没有安装在虚拟环境中。

Once I installed Jupyter within the virtual environment Jupyter notebook worked.一旦我在 Jupyter notebook 工作的虚拟环境中安装了 Jupyter。 Not sure why inheriting Jupyter from global packages wasn't working for me.不知道为什么从全局包继承 Jupyter 对我不起作用。

The above solution using a designated url with token seems to work with older versions of PyCharm.上述使用带有令牌的指定 url 的解决方案似乎适用于旧版本的 PyCharm。 A simpler solution is to upgrade to the latest PyCharm.一个更简单的解决方案是升级到最新的 PyCharm。 I no longer had an issue with the auto server using PyCharm 2019.3.2 (Mac)我不再遇到使用 PyCharm 2019.3.2 (Mac) 的自动服务器的问题

I had this problem with Datalore plugin enabled on 2020.2 linux, running on bare metal but displaying to a remote X server (probably doesn't matter).我在 2020.2 linux 上启用了 Datalore 插件时遇到了这个问题,在裸机上运行但显示到远程 X 服务器(可能无关紧要)。 My solution was to disable the Datalore plugin (it's enabled for professional pycharm by default).我的解决方案是禁用 Datalore 插件(默认情况下它已为专业 pycharm 启用)。

This way I was still able to use the "managed" auto-start version with better integration / debugging vs the "configured" option (or at least with less hassle).通过这种方式,我仍然能够使用“托管”自动启动版本,与“配置”选项相比,具有更好的集成/调试(或至少更少麻烦)。

Note since it's been a year, my problem is probably different than OP.请注意,因为已经一年了,我的问题可能与 OP 不同。

This happened for me, when the interpreter was a remote one.这发生在我身上,当口译员是远程翻译时。 I fixed this by changing the interpreter to one from a local env.我通过将解释器从本地环境更改为一个来解决这个问题。
This can be done by selecting the Configure Jupyter Server.这可以通过选择配置 Jupyter 服务器来完成。

在此处输入图片说明

I also meet this problem,and i solved it我也遇到这个问题,我解决了

i create the new project with the global sit-packages like below我使用如下所示的全局坐包创建新项目

在此处输入图片说明

then i meet the problem然后我遇到了问题

i create the new project with no global sit-packages and install jupyter notebook in the virtualenv我创建了没有全局坐包的新项目,并在 virtualenv 中安装了 jupyter notebook

在此处输入图片说明

then the problem is gone那么问题就解决了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM