设为首页 收藏本站
查看: 1048|回复: 0

[经验分享] centos7安装 jupyter

[复制链接]

尚未签到

发表于 2019-2-15 15:29:52 | 显示全部楼层 |阅读模式
  Jupyter Notebook(此前被称为 IPython notebook)是一个交互式笔记本,支持运行 40 多种编程语言。
  Jupyter Notebook 的本质是一个 Web 应用程序,便于创建和共享文学化程序文档,支持实时代码,数学方程,可视化和 markdown。 用途包括:数据清理和转换,数值模拟,统计建模,机器学习等等
  -------- 来至百度百科
  系统:
  centos7
  centos7默认是python2,依照官网进行安装
  # python -m pip install --upgrade pip
  # python -m pip install jupyter
  提示出错:
  Downloading
  setuptools-40.4.3-py2.py3-none-any.whl (569kB)
  wheel-0.32.1-py2.py3-none-any.whl
  ipython-7.0.1.tar.gz (5.1MB)
  Complete output from command python setup.py egg_info:
  IPython 7.0+ supports Python 3.5 and above.
  When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
  Python 3.3 and 3.4 were supported up to IPython 6.x.
  See IPython `README.rst` file for more information:
  https://github.com/ipython/ipython/blob/master/README.rst
  Python sys.version_info(major=2, minor=7, micro=5, releaselevel='final', serial=0) detected.
  
  可以看到,下载的ipython最少需要python3.3的支持
  编译python3
  安装依赖
  # yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
  备份
  # cd /usr/bin
  # mv python python.bak
  下载并编译
  # wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
  # tar -xvJf  Python-3.6.2.tar.xz
  # cd Python-3.6.2
  # ./configure prefix=/usr/local/python3
  # make && make install
  # ln -s /usr/local/python3/bin/python3 /usr/bin/python
  验证,同时存在python2和python3
  # python -V
  Python 3.6.2
  # python2 -V
  Python 2.7.5
  编辑yum和urlgrabber-ext-down
  执行yum需要python2,需要修改yum的配置
  # vi /usr/bin/yum
  #! /usr/bin/python
  >>
  #! /usr/bin/python2
  # vi /usr/libexec/urlgrabber-ext-down
  #! /usr/bin/python
  >>
  #! /usr/bin/python2
  依照官网进行安装
  # python3 -m pip install --upgrade pip
  # python3 -m pip install jupyter
  Successfully installed MarkupSafe-1.0 Send2Trash-1.5.0 backcall-0.1.0 bleach-3.0.0 decorator-4.3.0 defusedxml-0.5.0 entrypoints-0.2.3 ipykernel-5.0.0 ipython-7.0.1 ipython-genutils-0.2.0 ipywidgets-7.4.2 jedi-0.13.1 jinja2-2.10 jsonschema-2.6.0 jupyter-1.0.0 jupyter-client-5.2.3 jupyter-console-6.0.0 jupyter-core-4.4.0 mistune-0.8.3 nbconvert-5.4.0 nbformat-4.4.0 notebook-5.7.0 pandocfilters-1.4.2 parso-0.3.1 pexpect-4.6.0 pickleshare-0.7.5 prometheus-client-0.4.0 prompt-toolkit-2.0.5 ptyprocess-0.6.0 pygments-2.2.0 python-dateutil-2.7.3 pyzmq-17.1.2 qtconsole-4.4.1 simplegeneric-0.8.1 six-1.11.0 terminado-0.8.1 testpath-0.4.2 tornado-5.1.1 traitlets-4.3.2 wcwidth-0.1.7 webencodings-0.5.1 widgetsnbextension-3.4.2
  生成配置文件
  # jupyter notebook --generate-config
  Writing default config to: /root/.jupyter/jupyter_notebook_config.py
  生成密码
  # python3
  Python 3.6.2 (default, Nov  2 2018, 16:17:04)
  [GCC 4.8.5 20150623 (Red Hat 4.8.5-28.0.1)] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> from notebook.auth import passwd
  >>> passwd()
  此时会让你两次输入密码,然后就会生成秘钥
  修改配置文件
  # vi ~/.jupyter/jupyter_notebook_config.py
  # 设置所有IP皆可访问
  c.NotebookApp.ip = '0.0.0.0'
  c.NotebookApp.password = u'生成的密钥'
  # 禁止自动打开浏览器
  c.NotebookApp.open_browser = Flase
  # 服务端口
  c.NotebookApp.port = 8080
  这里需要注意的是c.NotebookApp.ip,这个配置项如果按照网上大多数的配置配置为*的话,就会出现下面的错误:
  # jupyter notebook
  [I 16:54:09.881 NotebookApp] Writing notebook server cookie secret to /run/user/13011/jupyter/notebook_cookie_secret
  Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/traitlets/traitlets.py", line 528, in get
  value = obj._trait_values[self.name]
  KeyError: 'allow_remote_access'
  During handling of the above exception, another exception occurred:
  Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 869, in _default_allow_remote
  addr = ipaddress.ip_address(self.ip)
  File "/usr/local/lib/python3.6/ipaddress.py", line 54, in ip_address
  address)
  ValueError: '' does not appear to be an IPv4 or IPv6 address
  During handling of the above exception, another exception occurred:
  Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 11, in
  sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance
  return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance
  app.initialize(argv)
  File "", line 2, in initialize
  File "/usr/local/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error
  return method(app, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 1629, in initialize
  self.init_webapp()
  File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 1379, in init_webapp
  self.jinja_environment_options,
  File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 158, in __init__
  default_url, settings_overrides, jinja_env_options)
  File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 251, in init_settings
  allow_remote_access=jupyter_app.allow_remote_access,
  File "/usr/local/lib/python3.6/site-packages/traitlets/traitlets.py", line 556, in __get__
  return self.get(obj, cls)
  File "/usr/local/lib/python3.6/site-packages/traitlets/traitlets.py", line 535, in get
  value = self._validate(obj, dynamic_default())
  File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 872, in _default_allow_remote
  for info in socket.getaddrinfo(self.ip, self.port, 0, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.6/socket.py", line 743, in getaddrinfo
  for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
  socket.gaierror: [Errno -2] Name or service not known
  需要注意版本信息,如果notebook为5.6.0以下版本,c.NotebookApp.ip = '*',为以上版本,则设置为c.NotebookApp.ip = '0.0.0.0'
  启动服务
  # jupyter notebook
  [C 17:02:44.143 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.
  根据提示使用root用户启动需要加入参数
  # jupyter notebook --allow-root
  [I 17:04:12.761 NotebookApp] Serving notebooks from local directory: /home/sphuser/Python-3.6.2
  [I 17:04:12.761 NotebookApp] The Jupyter Notebook is running at:
  [I 17:04:12.761 NotebookApp] http://(jupyterserver or 127.0.0.1):8080/
  [I 17:04:12.761 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
  打开 IP:指定的端口, 输入密码就可以访问了
  参考文档:
  http://jupyter.org/install.html
  https://www.cnblogs.com/JahanGu/p/7452527.html
  https://blog.csdn.net/qq_18293213/article/details/72910834
  https://my.oschina.net/mengyoufengyu/blog/2252687




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-672597-1-1.html 上篇帖子: centos7 redis集群增减节点 下篇帖子: vagrant(centos7)部署kubernetes实验环境
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表