jupyter notebook启动出错解决方法

今天在云服务器上安装了jupyter,按照官方教程安装完成。输入如下命令启动:

jupyter notebook

然后就报了下面的错

Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/home/ubuntu/.local/lib/python3.5/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/home/ubuntu/.local/lib/python3.5/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/notebook/notebookapp.py", line 1368, in initialize
    self.init_webapp()
  File "/home/ubuntu/.local/lib/python3.5/site-packages/notebook/notebookapp.py", line 1188, in init_webapp
    self.http_server.listen(port, self.ip)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/tornado/tcpserver.py", line 142, in listen
    sockets = bind_sockets(port, address=address)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/tornado/netutil.py", line 197, in bind_sockets
    sock.bind(sockaddr)
OSError: [Errno 99] Cannot assign requested address

根据报错信息来看是不能分配地址,这就莫名奇妙了,按说就算是以127.0.0.1或者是localhost应该也尅启动啊,怎么就无法启动了。经过不断探索终于找到解决方法。

1 . 输入如下命令:

jupyter notebook --ip=127.0.0.1

发现如果是指定本地ip是可以启动的,但是只能在本地访问,但是我是想在云服务器上启动,远程访问啊。

2 . 输入命令:

jupyter notebook --ip=云服务ip 

但是仍然提示前面的报错。
这时候联想到MySQL如果需要远程访问要更改配置文件,因为MySQL的配置文件默认绑定了127.0.0.1,那jupyter可能也是绑定了这个地址,那我们只需要更改配置文件就可以了。
搜索一番,发现原来新装的jupyter是没有配置文件的,需要手动生成,执行如下命令:

jupyter notebook --generate-config

就会在你的个人用户目录下的.jupyter 下生成配置文件 jupyter_notebook_config.py,打开以后找到如下一行:

#c.NotebookApp.ip = 'localhost'

改为

c.NotebookApp.ip = '*'

意思为允许所有ip连接,这样问题就解决了,希望可以帮助到有需要的人。

已标记关键词 清除标记
启动jupyter后anaconda报错,报错信息如下: [I 15:34:21.738 NotebookApp] The port 8888 is already in use, trying another port. [I 15:34:21.786 NotebookApp] JupyterLab beta preview extension loaded from C:\Users\10034\Anaconda3\lib\site-packages\jupyterlab [I 15:34:21.786 NotebookApp] JupyterLab application directory is C:\Users\10034\Anaconda3\share\jupyter\lab [W 15:34:21.793 NotebookApp] Error loading server extension jupyterlab Traceback (most recent call last): File "C:\Users\10034\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 321, in __init__ self._run(['node', 'node-version-check.js'], cwd=HERE, quiet=True) File "C:\Users\10034\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 1165, in _run proc = Process(cmd, **kwargs) File "C:\Users\10034\Anaconda3\lib\site-packages\jupyterlab\process.py", line 73, in __init__ self.proc = self._create_process(cwd=cwd, env=env) File "C:\Users\10034\Anaconda3\lib\site-packages\jupyterlab\process.py", line 131, in _create_process cmd[0] = which(cmd[0], kwargs.get('env')) File "C:\Users\10034\Anaconda3\lib\site-packages\jupyterlab\jlpmapp.py", line 59, in which raise ValueError(msg) ValueError: Please install nodejs 5+ and npm before continuing installation. nodejs may be installed using conda or directly from the nodejs website. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\10034\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 1454, in init_server_extensions func(self) File "C:\Users\10034\Anaconda3\lib\site-packages\jupyterlab\extension.py", line 111, in load_jupyter_server_extension info = get_app_info(app_dir) File "C:\Users\10034\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 244, in get_app_info handler = _AppHandler(app_dir, logger) File "C:\Users\10034\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 324, in __init__ raise ValueError(msg) ValueError: Please install nodejs 5+ and npm before continuing installation. nodejs may be installed using conda or directly from the nodejs website. [I 15:34:21.975 NotebookApp] Serving notebooks from local directory: C:\Users\10034 [I 15:34:21.975 NotebookApp] 0 active kernels [I 15:34:21.976 NotebookApp] The Jupyter Notebook is running at: [I 15:34:21.976 NotebookApp] http://localhost:8889/?token=292dce07942e7e31c953a749027b2d327e20ad449cef8ccd [I 15:34:21.976 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 15:34:21.977 NotebookApp] Copy/paste this URL into your browser when you connect for the first time, to login with a token: http://localhost:8889/?token=292dce07942e7e31c953a749027b2d327e20ad449cef8ccd [I 15:34:23.630 NotebookApp] Accepting one-time-token-authenticated connection from ::1 我猜应该是我反复安装anaconda导致的问题,请问有大佬帮忙解决吗?
©️2020 CSDN 皮肤主题: 成长之路 设计师:Amelia_0503 返回首页