安装jupyter

1.安装与配置
第一步:安装jupyter
参考:Ubuntu 安装 Anaconda3 详细步骤

或者可以使用:

pip3 install jupyter (此处使用的是python3)
第二步:生成配置文件jupyter notebook --generate-config

第三步:生成密钥 打开python3 ,然后输入

  1. from notebook.auth import passwd
  2. passwd()
  3. 此时会让你两次输入密码,然后就会生成秘钥
  4. ************
    修改配置文件

sudo vi ~/.jupyter/jupyter_notebook_config.py
大约在200行的位置,找到下面配置

  1. c.NotebookApp.ip=’*’ # 就是设置所有ip皆可访问

  2. c.NotebookApp.ip=‘0.0.0.0’

"start of jupyter notebook server on ip adress ‘0.0.0.0’ instead of default ‘*’ which is no longer supported this is probably needed only on a temporary basis see also

https://github.com/jupyter/docker-stacks/issues/718
https://github.com/ageron/handson-ml/pull/317/commits")
2. c.NotebookApp.password = u’sha:ce… # 刚才复制的那个密文’
3. c.NotebookApp.open_browser = False # 禁止自动打开浏览器
4. c.NotebookApp.port =8888 #随便指定一个端口
第四步:配置一下路由器的端口转发,

第五步:在服务器端启动 jupyter notebook

第六步:本地地址栏输入服务器ip:8888 就OK了

2.打开 Jupyter Notebook
打开 notebook 的方法非常简单,只需在终端输入

ipython notebook
3.退出
在ubuntu终端运行jupyter notebook后打开了jupyter的网页,在关闭jupyter的网页后如何在ubuntu终端退出jupyter notebook重新进入命令输入行呢?

同时按下ctrl和C键,然后按照下面终端界面提示操作就可以了。

pip查看已安装的包

pip show --files SomePackage

Name: SomePackage
Version: 1.0
Location: /my/env/lib/pythonx.x/site-packages
Files:
…/somepackage/init.py
[…]
参考pip安装使用详解

4.安装python2 kernal
sudo python2 -m pip install --user --ignore-installed python-dateutil ipykernel
jupyter kernel查看内核

jupyter kernelspec list
卸载内核

jupyter kernelspec remove kernelname
5. ubuntu 中jupyter notebook python2&3 并存使用
在终端输入
$python2 -m pip install ipykernel
$python2 -m ipykernel install --user

$python3 -m pip install ipykernel
$python3 -m ipykernel install --user

----------------------
Kernels for Python 2 and 3

出现问题:
Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/usr/local/lib/python2.7/dist-packages/ipykernel_launcher.py”, line 15, in
from ipykernel import kernelapp as app
File “/usr/local/lib/python2.7/dist-packages/ipykernel/init.py”, line 2, in
from .connect import *
File “/usr/local/lib/python2.7/dist-packages/ipykernel/connect.py”, line 14, in
from IPython.paths import get_ipython_dir
ImportError: No module named paths

solution
这是由于系统自带ipython版本与jupyter冲突。

This is because of version conflict of ipython installed by apt-get package manager and ipython by pip:

so uninstall all versions of ipython from apt-get as follows:

sudo apt-get remove ipython ipython-notebook ipython-notebook-common
also remove from pip: both jupyter and ipython

sudo pip uninstall jupyter
sudo pip uninstall ipython
As ipython is part of jupyter, so just reinstall jupyter

sudo pip install jupyter
This should help!!!

附注:使用Anaconda管理不同版本
The idea here is to install multiple ipython kernels. Here are instructions for anaconda. If you are not using anaconda, I recently added instructions using pure virtualenvs.

Anaconda 4.1.0
Since version 4.1.0, anaconda includes a special package nb_conda_kernels that detects conda environments with notebook kernels and automatically registers them. This makes using a new python version as easy as creating new conda environments:

conda create -n py27 python=2.7 ipykernel
conda create -n py36 python=3.6 ipykernel
After a restart of jupyter notebook, the new kernels are available over the graphical interface. Please note that new packages have to be explicitly installed into the new enviroments. The Managing environments section in conda’s docs provides further information.

Manually registering kernels
Users who do not want to use nb_conda_kernels or still use older versions of anaconda can use the following steps to manually register ipython kernels.

configure the python2.7 environment:

conda create -n py27 python=2.7
source activate py27
conda install notebook ipykernel
ipython kernel install --user
configure the python3.6 environment:

conda create -n py36 python=3.6
source activate py36
conda install notebook ipykernel
ipython kernel install --user
After that you should be able to choose between python2
and python3 when creating a new notebook in the interface.

Additionally you can pass the --name and --display-name options to ipython kernel install if you want to change the names of your kernels. See ipython kernel install --help for more informations.

  1. Jupyter使用
    参考Jupyter Notebook使用笔记(一)

两种模式
Command mode 和 Edit mode。 在一个cell中,按下Enter,进入Edit模式,按下Esc,进入Command 模式

运行当前cell,并移动到下一个Cell
在一个cell中(在command模式下), Shift + Enter

创建Cell
在一个cell中(在command模式下)
1. 按下 a ,即可在这个cell之前创建一个新的cell;
2. 按下 b,即可在这个cell之后创建一个新的cell;

Cell中 Code 和 Markdown的切换
在一个cell中(在command模式下)
1. 按下 y, 进入Code;
2. 按下m, 进入Markdown;

显示Cell中的行数
在一个cell中(在command模式下),按下 l

删除Cell
在一个cell中(在command模式下), 按两次 d

保存Notebook
在一个cell中(在command模式下), 按下 s

启动命令面板
在一个cell中(在command模式下), 按下 Ctrl + Shift + P
界面中的小键盘也可以启动:

可以通过这个命令面板快速的执行命令。比如我这里将一个cell移动到它下一个cell的下面:在一个cell中(在command模式下),然后按下 Ctrl + Shift + P ,输入 move ,键盘方向键选择要执行的命令即可,然后按下回车即可执行。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值