如何在pyCharm中的jupyter中指定python3内核?

时间:2017-07-04 09:55:41

标签: python pycharm jupyter-notebook jupyter

这是我的设置 enter image description here 这是我的剧本 enter image description here

我正在尝试在pyCharm中使用jupyter笔记本,但它继续使用python2而不是python3。

对这个问题有什么想法吗?

添加:

这张照片是用chrome运行的jupyter笔记本。 enter image description here

3 个答案:

答案 0 :(得分:0)

您显示的首选项图像确实是您为PyCharm设置解释器的方式,但这并不是PyCharm的输出/日志记录的样子。我猜这是一个jupyter-notebook显示器,这意味着你在jupyter-notebook而不是PyCharm中遇到了这个问题。因此,您需要更改jupyter的设置。基于一些快速搜索pip install jupyter将安装一个python 2.7版本的jupyter。听起来像你想要的是

pip3 install jupyter

将为您安装python3版本。您可能必须卸载当前版本的jupyter。

答案 1 :(得分:0)

当您从PyCharm中启动Jupyter-notebook时,会创建一个配置。如果配置最初是2.7(我认为它默认为当前解释器),然后继续使用相同的配置,那么当前项目解释器的状态并不重要,因为它将使用运行中保存的值配置。

您可以通过

修改运行配置
  1. Run | Run...
  2. enter image description here

    1. Edit Configurations...
    2. enter image description here

      1. Select your Jupyter Notebook run configuration on the left(此处为无标题4)

      2. Make sure the python interpreter is correct here on the right

      3. enter image description here

        我能够像这样启动一个jupyter笔记本并通过这样做来输出python 3。希望这是你需要的。

答案 2 :(得分:0)

我的问题是我有多个内核,而PyCharm启动了默认内核。一种方法可能是配置PyCharm以指定要启动的首选内核,我没有研究如何做到这一点。我只是在Jupyter中更改了默认内核,这对我有用(我为tensorflow提供了virtualenv)。 c.MultiKernelManager.default_kernel_name = 'tensorflow'