ubuntu Anaconda 安装jupyter notebook

记录一下ubuntu安装jupyter notebook的过程

在/opt目录下下载Anaconda3-5.2.0-Linux-x86_64.sh

wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh

安装Anaconda

sh Anaconda3-5.2.0-Linux-x86_64.sh

默认安装在/root/anaconda3下面
配置环境变量

vim /etc/profile
export PATH=/root/anaconda3/bin:$PATH

立即生效

source /etc/profile

生成jupyter notebook配置文件

jupyter notebook --generate-config --allow-root

生成密码

Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from notebook.auth import passwd

In [2]: passwd()
Enter password: 
Verify password: 
Out[2]: 'sha1:1bd02967d36a:4cb1f312446313eb78ba15a29b6b3587eb75ae0d'

In [3]: 

修改配置文件

vim /root/.jupyter/jupyter_notebook_config.py 

c.NotebookApp.ip = '0.0.0.0'            即对外提供访问的ip
c.NotebookApp.port = 8888                    即对外提供访问的端口
c.NotebookApp.open_browser = False            False即启动不打开浏览器
c.NotebookApp.password = u'sha1:f8b5f5dbeca8:d1f5b93d5e787e4bf1bf4ad2c48c177ba79f55dd'   这个就是上面生成的秘钥
c.NotebookApp.notebook_dir = u'/search/autotest/jupyter_dir' 即设置jupyter启动后默认的根目录

如果是在docker里面启动需要下面的设置

c.NotebookApp.allow_remote_access = True
c.NotebookApp.allow_root = True

启动

nohup jupyter notebook --allow-root >/dev/null 2>&1 &

conda管理环境

创建一个虚拟环境

conda create --name snowflakes biopython

上面命令行作用是在/envs/snowflakes创建一个虚拟环境并安装biopython包,并且python的版本和root环境里面一样,默认就是这样

conda create --name bunnies python=3.5 astroid babel

上面命令行的作用是在/envs/bunnies创建一个Python版本为3.5的虚拟环境,并安装astroid 和babel两个包

列出所有的环境

conda info --envs

可以看到输出为

conda environments:

     snowflakes          * /home/username/miniconda/envs/snowflakes
     bunnies               /home/username/miniconda/envs/bunnies
     root                  /home/username/miniconda

其中*号代表目前所在环境, --envs 和-e作用一样

切换环境

  • Linux, OS X: source activate bunnies
  • Windows: activate bunnies

克隆一个环境

conda create --name flowers --clone snowflakes

删除一个环境

conda remove --name flowers --all

管理Python

conda search --full-name python

列出所有python版本,如果不加--full-name会列出所有包名里面包含'python'的包

conda create --name snakes python=3

创建了一个python版本为3的snakes环境

管理包

conda search beautifulsoup4

上面命令行的作用是搜索beautifulsoup4包

conda install --name bunnies beautifulsoup4

上面命令行的作用是在指定的环境bunnies中安装beautifulsoup4包

pip install see

如果conda找不到,就用pip进行安装

conda remove --name bunnies iopro

在指定环境bunnies中移除包iopro

多核处理

pip install ipykernel

python -m ipykernel install --user --name pytorchLearn --display-name "pytorchLearn"
    Installed kernelspec pytorchLearn in /root/.local/share/jupyter/kernels/pytorchlearn

如果是windows存放在

C:\Users\24968\AppData\Roaming\jupyter\kernels\pytorch

你可能感兴趣的:(ubuntu Anaconda 安装jupyter notebook)