How to specify python3 kernel in jupyter in pyChar

2019-04-30 08:09发布

Here is my setting enter image description here and this is my script enter image description here

I am trying to use jupyter notebook in pyCharm, but it kept using python2 instead of python3.

Any idea about this problem?

Add:

this pic is running jupyter notebook in chrome. enter image description here

3条回答
The star\"
2楼-- · 2019-04-30 08:13

My problem was that I had multiple kernels, and PyCharm launches the default kernel. One approach might be to configure PyCharm to specify the kernel of choice to start up, I didn't investigate how to do that. I simply changed the default kernel in Jupyter and this worked for me (I have a virtualenv for tensorflow). c.MultiKernelManager.default_kernel_name = 'tensorflow'.

查看更多
smile是对你的礼貌
3楼-- · 2019-04-30 08:16

The preferences image you show is indeed how you would setup your interpreter for PyCharm, but that's not what the output/logging of PyCharm looks like. I'm guessing that's a jupyter-notebook display, which means you are running into the issue in jupyter-notebook and not PyCharm. So you need to change your setup for jupyter. Based on some quick searching pip install jupyter will install a python 2.7 version of jupyter. Sounds like what you want is

pip3 install jupyter

which will install the python3 version for you. You will likely have to uninstall your current version of jupyter.

查看更多
相关推荐>>
4楼-- · 2019-04-30 08:16

When you kick off Jupyter-notebook from within PyCharm there is a configuration which is created. If the configuration is initially 2.7 ( I think it defaults to the current interpreter), and then keep using that same configuration, it wouldn't matter the state of the current project interpreter because it would be using the value saved in the run configuration.

You can modify your run configuration by

  1. Run | Run...

enter image description here

  1. Edit Configurations...

enter image description here

  1. Select your Jupyter Notebook run configuration on the left (here is untitled4)

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

enter image description here

I was able to start a jupyter notebook like this and get it to output python 3 by doing this. Hope this is what you are needing.

查看更多
登录 后发表回答