jupyter

Pycharm安装并配置jupyter notebook

2018-08-07  本文已影响0人  winddy_akoky

Pycharm安装并配置jupyter notebook

一: 安装命令jupyter: pip install jupyter

如果缺少依赖,缺啥装啥

二: 运行 jupyter notebook

jupyter notebook

如果运行成功,结果如下:

[I 09:03:15.177 NotebookApp] JupyterLab beta preview extension loaded from /home/winddy/anaconda3/lib/python3.6/site-packages/jupyterlab
[I 09:03:15.177 NotebookApp] JupyterLab application directory is /home/winddy/anaconda3/share/jupyter/lab
[I 09:03:15.182 NotebookApp] Serving notebooks from local directory: /home/winddy
[I 09:03:15.182 NotebookApp] 0 active kernels
[I 09:03:15.182 NotebookApp] The Jupyter Notebook is running at:
[I 09:03:15.182 NotebookApp] http://localhost:8888/?token=c19f036f3beb2bce5112ca9c2f4565e738175a9853302e44
[I 09:03:15.182 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:03:15.183 NotebookApp] 
    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=c19f036f3beb2bce5112ca9c2f4565e738175a9853302e44&token=c19f036f3beb2bce5112ca9c2f4565e738175a9853302e44
[I 09:03:15.693 NotebookApp] Accepting one-time-token-authenticated connection from ::1
Created new window in existing browser session.
[W 09:03:16.282 NotebookApp] Error stat-ing /home/winddy/.gvfs: [Errno 13] Permission denied: '/home/winddy/.gvfs'

从上面可以知道,Jupyter notebook 生成的服务器地址为:http://localhost:8888/?token=c19f036f3beb2bce5112ca9c2f4565e738175a9853302e44 其中端口号为8888,注意,如果你打开多个Jupyter notebook , 那么每一个服务的端口号是不一样的

三: 上面都执行成功后,在pycharm 配置 jupyter notebook

这里巨坑,pycharm 的官网都JB坑

先给无差错的配置结果

  1. 在pycharm 新建一个后缀名为:.ipynb 的文件,如果你的pycharm没有解析改后缀名的插件,按照提示默认装好插件就可以

  2. 在第一个cell中输入: %matplotlib inline


    Selection_001.png
  3. 点击运行按钮,这时,用户会因为环境不同会报各种错,这个放在后面讲


    Selection_002.png
  4. 点击后pycharm会弹出一个会话框


    Selection_003.png

注意,你可以在这个会话框中填入服务器地址,但是,我们这里只想在本地编辑,所以直接点取消, 然后出现

Selection_004.png

他会说不能连接到Jupyter notebook, 我们不管这个提示,因为我们只想在本地编辑,所以直接点击 run Jupyter notebook
!!!!!!到这里,如果没出现错误的话,pycharm会直接帮你启动服务并运行你指定的代码

Selection_005.png

(如果,你看到这个界面,那说明就OJBK了)

  1. 填写测试代码,逐个运行


    Selection_006.png

四: 常见错误

[I 09:02:18.636 NotebookApp] JupyterLab beta preview extension loaded from /home/winddy/anaconda3/lib/python3.6/site-packages/jupyterlab
[I 09:02:18.636 NotebookApp] JupyterLab application directory is /home/winddy/anaconda3/share/jupyter/lab
[C 09:02:18.641 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.
sudo chmod 777 jupyter/
Permission denied: '/home/winddy/.local/share/jupyter/kernels'

上一篇下一篇

猜你喜欢

热点阅读