如何为 Anaconda/Jupyter 设置默认环境? [英] How to set a default environment for Anaconda / Jupyter?

查看:44
本文介绍了如何为 Anaconda/Jupyter 设置默认环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为我的机器学习课程安装了 Anaconda.我将它用作 IPython (Jupyter) 笔记本,我们在其中上课.操作系统是 Ubuntu 14.04 LTS.基本上,我总是从终端运行它:

I have installed Anaconda for my Machine Learning course. I'm using it as IPython (Jupyter) notebook, in which we have lessons. OS is Ubuntu 14.04 LTS. Basically, I always run it from Terminal with:

jupyter notebook

我从 root 环境(精确副本)创建了名为 su_env 的新环境,并添加了一个包.现在,我想知道:如何将环境 su_env 设置为默认环境?我有十几个笔记本,所以每次都在 Jupyter 的网络"GUI 中为每个笔记本设置环境很烦人.

I have created new environment called su_env from root environment (exact copy) with one package added. Now, I'm wondering: how can I set environment su_env as default one? I have dozen of notebooks so it's annoying to set up each time for every notebook the environment, in "web" GUI of Jupyter.

我对在运行笔记本之前不必设置环境的解决方案感兴趣.我的逻辑是,以某种方式,jupyter 在启动时自动设置 root 环境.因此,我想知道是否可以设置一些配置文件或其他内容,以便 jupyter 设置 su_env 而不是 root.另外,如果您知道这是不可能的(以及为什么),我想知道.

I'm interested in a solution where you don't have to set environment before running notebook. My logic is that, somehow, automagically, jupyter sets root environment on its own while starting up. Because of that, I'm wondering is it possible to set some config file or something so jupyter sets su_env instead of root. Also, if you know that's not possible (and why), I would like to know that.

推荐答案

首先从命令行激活 conda 环境,然后启动 notebook 服务器.

First activate the conda environment from the command line, then launch the notebook server.

例如:

$ source activate env_name
$ jupyter notebook

注意:这可能仅适用于从 Jupyter Notebook 中创建的环境,不适用于在命令行上使用 conda create 创建的环境.

Note: This might only work with environments that were created from within Jupyter Notebook, not environments that were created using conda create on the command line.

这篇关于如何为 Anaconda/Jupyter 设置默认环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆