linux下安装Anaconda以及配置jupyter的远程访问
文章目录
前言
已经有超过三人像我反应使用网上的教程Anaconda有问题,有的装不了,有的装的直接整的自己yum命令用不了,linux服务器都被整费。为此我给大家写的简单的安装教程,避免大家可能踩的坑。
下载Anaconda
去 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive或https://repo.anaconda.com/archive/选择你要安装的版本,
前者是清华源国内访问相对网速非常快,但清华园是定期的不让访问,如果你也中奖就只能通过后者官网的地址去下载。
经过无数次的实践证明,python3.6版本是最稳定的,另外我的linux服务器是64位,为了更快的性能,所以我选择下载64位,所以最终我通过以下命令,直接在linux服务器上下载:
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.2.0-Linux-x86_64.sh
如果清华园失效无法下载,那你需要使用命令:
wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh
慢慢下。
安装
执行:
sh Anaconda3-5.2.0-Linux-x86_64.sh
Please, press ENTER to continue [root@VM_0_9_centos ~]#sh Anaconda3-5.2.0-Linux-x86_64.sh Welcome to Anaconda3 5.2.0 In order to continue the installation process, please review the license agreement. Please, press ENTER to continue >>> =================================== Anaconda End User License Agreement =================================== ...
先直接回车,再按q。
询问是否同意协议,填yes:
Do you accept the license terms? [yes|no] [no] >>> yes
选择安装位置,直接回车就安装在当前路径,我选择安装在/opt/anaconda3目录下:
Anaconda3 will now be installed into this location: /root/anaconda3 - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below [/root/anaconda3] >>> /opt/anaconda3 PREFIX=/opt/anaconda3 installing: python-3.6.5-hc3d631a_2 ... Python 3.6.5 :: Anaconda, Inc. installing: blas-1.0-mkl ... installing: ca-certificates-2018.03.07-0 ... installing: conda-env-2.6.0-h36134e3_1 ... installing: intel-openmp-2018.0.0-8 ... ... installing: seaborn-0.8.1-py36hfad7ec4_0 ... installing: anaconda-5.2.0-py36_3 ... installation finished.
经过几分钟的等待后,主程序安装完成。询问是否将Anaconda3加入到环境变量,直接回车表示no,不添加:
Do you wish the installer to prepend the Anaconda3 install location to PATH in your /root/.bashrc ? [yes|no] [no] >>> You may wish to edit your .bashrc to prepend the Anaconda3 install location to PATH: export PATH=/opt/anaconda3/bin:$PATH Thank you for installing Anaconda3!
然后询问是否安装VSCode,填no并回车,表示不安装:
Do you wish to proceed with the installation of Microsoft VSCode? [yes|no] >>> no
此时安装程序已经结束,然后我们执行:
echo ". /opt/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc sudo ln -s /opt/anaconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh
注意:/opt/anaconda3换成你所安装的位置。
使用anaconda
退出shell后,重新登陆,然后就可以使用anaconda了:
进入环境:conda activate 退出环境: conda deactivate
[root@VM_0_9_centos ~]# conda activate (base) [root@VM_0_9_centos ~]# python Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> exit() (base) [root@VM_0_9_centos ~]# conda deactivate [root@VM_0_9_centos ~]# python Python 2.7.5 (default, Jun 20 2019, 20:27:34) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> exit() [root@VM_0_9_centos ~]#
配置jupyter支持远程访问
生成jupyter默认配置:
jupyter notebook --generate-config (base) [root@VM_0_9_centos ipython]# jupyter notebook --generate-config Writing default config to: /root/.jupyter/jupyter_notebook_config.py
修改配置:
(base) [root@VM_0_9_centos ipython]# vi ~/.jupyter/jupyter_notebook_config.py
取消
c.NotebookApp.ip = 'localhost'的注释并改成
c.NotebookApp.ip = '*'即可。
运行jupyter:
jupyter notebook --allow-root
然后本地顺利访问到远程主机上的jupyter:
jupyter当前主目录取决于命令执行时所在的目录。
配置jupyter使用密码访问
将要配置的密码使用passwd函数处理:
(base) [root@VM_0_9_centos bak]# python Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from notebook.auth import passwd >>> passwd() Enter password: Verify password: 'sha1:13c0e9e600be:b1caae19615389900ba30f072caf1c5f4dd388b1' >>>
上面Enter password和Verify password的输入不会回想,两次输入你需要配置的密码回车,即可得到sha1码。
例如我配置的密码是123456,则sha1码是
sha1:13c0e9e600be:b1caae19615389900ba30f072caf1c5f4dd388b1
再编辑下jupyter配置:
vi ~/.jupyter/jupyter_notebook_config.py
取消
c.NotebookApp.password = ''的注释,改为
c.NotebookApp.password = 'sha1:13c0e9e600be:b1caae19615389900ba30f072caf1c5f4dd388b1'
其他配置:
c.NotebookApp.allow_root = True: root用户下执行不需要加–allow-root参数
c.NotebookApp.open_browser = False: 启动默认不打开游览器
再次运行jupyter:
jupyter notebook
此时再访问jupyter,需要输入密码:
后台运行jupyter
让jupyter即使关闭shell也后台运行:
nohup jupyter notebook > jupyter.log 2>&1 &
关闭后台运行的jupyter:
(base) [root@VM_0_9_centos bak]# ps -ef|grep jupyter root 3646 28946 1 19:47 pts/1 00:00:00 /opt/anaconda3/bin/python /opt/anaconda3/bin/jupyter-notebook root 3771 28946 0 19:48 pts/1 00:00:00 grep --color=auto jupyter (base) [root@VM_0_9_centos bak]# kill 3646 (base) [root@VM_0_9_centos bak]# ps -ef|grep jupyter root 3861 28946 0 19:48 pts/1 00:00:00 grep --color=auto jupyter
- Ubuntu环境下Anaconda安装TensorFlow并配置Jupyter远程访问
- 集群linux下安装Anaconda和jupyter,设置远程访问
- DB2 V9 Linux下安装配置以及配置windows客户段的远程访问
- Ubuntu环境下Anaconda安装TensorFlow并配置Jupyter远程访问
- Linux安装anaconda2(python2.7环境)并配置远程jupyter
- 安装mysq 在linux,以及配置权限, 让某个账户能远程访问并且访问所有数据库
- Linux 关于安装rabbitmq以及开启远程访问权限步骤
- rabbitmq安装后的配置操作--远程访问以及开启web控制台
- linux下python安装(Anaconda)和ipython远程服务器链接配置
- linux上安装mysql并配置远程访问
- 图形界面远程访问Linux(Debian安装VNC以及开机启动)
- Linux下Mongodb安装和启动配置,远程访问等
- Linux环境下mysql安装并配置远程访问
- Linux下安装Redis以及配置远端访问
- linux下使用yum安装mysql以及启动、登录和远程访问
- Linux工具使用之MySQL安装(含配置远程访问)
- Anaconda自定义配置以及远程登录jupyter
- Linux安装Mysql与Mysql的远程访问配置
- Jupyter notebook在mac:linux上的配置和远程访问的方法
- Linux centos 6 中安装 MySQL 8.0 以及设置远程访问