设置Python虚拟环境启动Jupyter Notebook gaierror:[Errno -2]名称或服务未知

时间:2018-11-09 20:51:34

标签: hadoop pyspark jupyter-notebook

当我尝试在虚拟环境中启动Jupyter笔记本时,出现以下错误-.gaierror:[Errno -2]名称或服务未知

虚拟环境-wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-12.0.7.tar.gz

Traceback (most recent call last):
  File "/home/vraja/pyspark/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/home/vraja/pyspark/lib/python2.7/site- 
    packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/vraja/pyspark/lib/python2.7/site- 
   packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/home/vraja/pyspark/lib/python2.7/site- 
  packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/home/vraja/pyspark/lib/python2.7/site- 
  packages/notebook/notebookapp.py", line 1629, in initialize
    self.init_webapp()
  File "/home/vraja/pyspark/lib/python2.7/site- 
  packages/notebook/notebookapp.py", line 1379, in init_webapp
    self.jinja_environment_options,
  File "/home/vraja/pyspark/lib/python2.7/site- 
  packages/notebook/notebookapp.py", line 158, in __init__
    default_url, settings_overrides, jinja_env_options)
  File "/home/vraja/pyspark/lib/python2.7/site- 
  packages/notebook/notebookapp.py", line 251, in init_settings
    allow_remote_access=jupyter_app.allow_remote_access,
  File "/home/vraja/pyspark/lib/python2.7/site- 
  packages/traitlets/traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "/home/vraja/pyspark/lib/python2.7/site- 
  packages/traitlets/traitlets.py", line 535, in get
    value = self._validate(obj, dynamic_default())
  File "/home/vraja/pyspark/lib/python2.7/site- 
  packages/notebook/notebookapp.py", line 872, in _default_allow_remote
     for info in socket.getaddrinfo(self.ip, self.port, 0, 
     socket.SOCK_STREAM):
     socket.gaierror: [Errno -2] Name or service not known
(pyspark)-sh-4.1$

2 个答案:

答案 0 :(得分:0)

您是否设置了配置文件变量?..

请在配置文件中添加以下env变量。

导出PYSPARK_DRIVER_PYTHON = jupyter

导出PYSPARK_DRIVER_PYTHON_OPTS ='笔记本'

答案 1 :(得分:0)

根据https://github.com/jupyterlab/jupyterlab/issues/5410将NotebookApp.ip ='*'更改为NotebookApp.ip ='0.0.0.0'(Pazitos10注释)