转自:https://evidencen.com/how-to-create-export-and-import-anaconda-environments/

目录

  • How to create anaconda environment and make it available in Jupyter lab.
    • How to create anaconda environment from anaconda navigator
    • How to create anaconda environment from (anaconda prompt in windows, terminal on mac) and make it available in Jupyter lab.
      • How to install packages in anaconda environment (2 ways)
    • Adding Virtual Environment to Jupyter Lab
  • How to Export anaconda environments.
  • How to Import anaconda environments.

How to create anaconda environment and make it available in Jupyter lab.

There are 2 ways to create anaconda environments. You can create anaconda environment from anaconda prompt command line or from anaconda navigator.

How to create anaconda environment from anaconda navigator

Step 1: Open anaconda navigator

Step 2: click on “environment” located on the left side of the screen

Step 3: Click on “create” located on the bottom of the screen.

Step 4: Type in the name of the new environment–>choose python and/or R installation–>and click create.

Note: Make sure the name you give the new environment has never been used before.

Step 5: Add packages to the new environment by clicking the environment name

  • Search for the package you want in the search bar–>click on “ALL” from the drop down menu.

  • Select the name of the package you want to install, then click “apply” located in the lower right side of the screen.

  • Clicking apply installs the selected package.


How to create anaconda environment from (anaconda prompt in windows, terminal on mac) and make it available in Jupyter lab.

If you are looking to create an anaconda environment for a specific project using your command line, then follow these instructions.

Step 1: Navigate to the folder that contains the project you are working on using anaconda prompt on windows or terminal on mac

Step 2: Run conda create -n Environment-name python==3.7

Once the command completes, your conda environment should be ready

Next step is to add the required python packages. You will need to ‘activate’ the conda environment to add packages.

Step 3: To activate anaconda environment, type in source activate Environment-name on Terminal or conda activate Environment-name on Anaconda Prompt

How to install packages in anaconda environment (2 ways)

After activating your conda environment, you may want to install the packages for the project from the terminal. You can also install the packages for the project from anaconda navigator using STEP 5 FROM ABOVE.

OR…you can also use the instructions below to install package in your anaconda environment.

To install the required packages from the terminal, create a document called “requirements.txt” that has all the packages you will need to install. Here is an example of what it looks like.

This document should be on the folder/directory that has the project you are working on.

Step 4: Once your environment is activate, run pip install -r requirements.txt which will install the required packages into your environment.

You could alternatively install the package individually by doing pip install package name. But be warned, it is better to put the packages in a requirements.txt file and install it from there.

Adding Virtual Environment to Jupyter Lab

To make the environment available in jupyterlab, we need to add an Ipython Kernel reference to the conda environment, so we can use it from JupyterLab.

To add conda environment to jupyter lab,

Step 5: run python -m ipykernel install --user --name Environment-name --display-name "what you want jupyterlab environment called"

This will add a json object to an ipython file, so JupterLab will know that it can use this isolated instance of Python environment.

Step 6: Deactivate your conda environment and launch JupyterLab. You should now see “what you want jupyterlab environment called” in the list of available kernels on jupyter lab launch screen.

Step 7: Run conda deactivate to deactivate your environment


How to Export anaconda environments.

First, go to your terminal and follow the steps below. I have not found how to export anaconda environment using anaconda navigator, so the terminal is our only option.

Step 1: Activate the environment to export by typing: conda activate myenv

On Mac, type source activate myenv

Step 2: Export your active environment to a new file by typing: conda env export > environment.yml

On Mac, do source env export > environment.yml

Go the directory you are currently working on and you will find your environment.yml file.

Step 3: . Deactivate your conda environment after you are done by running conda deactivate.


How to Import anaconda environments.

To import anaconda environments, you can do it from anaconda navigator

Step 1: Open anaconda navigator and click on environments

Step 2: Click on import located on the bottom of the screen.

Step 3: Give the environment a new name,

  • Click the folder icon and select the environment.yml file you exported in the last section
  • Then click import
  • Wait a few minutes and the environment will be imported along with it’s dependencies.

    更多信息参考anaconda官方文档——管理环境

通过Anaconda管理环境相关推荐

  1. pycharm使用anaconda管理环境的设置实践

    pycharm使用anaconda管理环境的设置实践: 不点击3时候,只有几个pip安装包在下面环境可见,点击了下图中3后,则显示出了该环境x-optimization下所安装的所有安装包 其它找不到 ...

  2. 【日常学习】使用anaconda管理环境并安装cuda和cudnn和tensorflow

    目录 安装anaconda 管理环境 安装cuda 9.0和cudnn7 minianaconda miniconda的安装与使用 - 简书 安装anaconda Ubuntu 20.04安装Anac ...

  3. anaconda管理环境

    管理环境 创建并激活一个环境 使用"conda create"命令,后边跟上你希望用来称呼它的任何名字: conda create --name snowflake biopyth ...

  4. 使用Anaconda进行环境和包的管理

    有关概念和思想参考:https://blog.csdn.net/goodshot/article/details/54911834 使用conda  首先我们将要确认你已经安装好了conda 配置环境 ...

  5. 【python】anaconda 管理 python 环境

    anaconda 管理虚拟环境 anaconda 简介 python 虚拟环境的安装 查看当前 anaconda中所有的虚拟环境 创建新的虚拟环境 激活所创建的虚拟环境 删除指定的虚拟环境 退出当前虚 ...

  6. 【Anaconda】Windows丨管理环境、管理包

    Anaconda本质上就是包管理器和环境管理器 下面介绍Windows10系统下Anconda的使用,以下命令均在Anconda Prompt下运行 管理conda 查看conda版本 conda - ...

  7. Anaconda多环境多版本python配置指导

    Anaconda多环境多版本python配置指导: http://www.jianshu.com/p/d2e15200ee9b 原博客是翻译的官方文档,再加上自己的部分内容,官方原文地址:http:/ ...

  8. Anaconda多环境多版本python配置笔记

    一.Conda测试过程: 使用conda.首先确认已经安装好了conda 配置环境.下一步通过创建几个环境来展示conda的环境管理功能.学习如何确认在哪个环境中,以及如何做复制一个环境作为备份. 测 ...

  9. LInux 下 Anaconda多环境切换

    转自猴子链接:https://www.zhihu.com/question/58033789/answer/254673663 1. 如何管理包? 安装了 Anaconda 之后,就可以很方便的管理包 ...

最新文章

  1. 10个顶级的CSS UI开源框架
  2. laravel定时任务
  3. string类的erase函数属于stl吗_探索STL容器:vector
  4. 后疫情时代,人工智能发展的四大趋势
  5. 大数据平台的元数据管理
  6. 浙江日报软件测试怎么样,浙江日报
  7. 2D游戏案例:雷霆战机
  8. 目标跟踪OTB评估指标(OP, CLE, FPS)与matlab代码
  9. android安卓远程协助控制电脑PC端
  10. 学堂在线数据结构上6
  11. PyCharm调试时一直显示collecting data
  12. 液体倒进电脑了怎么办
  13. 博客样式(动态背景线条跟随鼠标移动)
  14. 华为写代码的这13年,成为了我最宝贵的人生历程
  15. 第十八篇:针对2022年网络系统管理赛项国赛样题的分析与思考
  16. ts 简单的对象深拷贝
  17. 李兴华Java培训系列课程
  18. Java Json Binding JSON-B使用示例
  19. iOS 准确获取 iPhone 状态栏、导航栏、TabBar高度,看这篇就够了
  20. Termux个人云盘搭建——kodbox

热门文章

  1. Python pywin32实现word和Excel的处理
  2. Linux下查看日志用到的常用命令
  3. ASIC-WORLD Verilog(2)FPGA的设计流程
  4. Beautiful Numbers
  5. 快捎携手信站大全步入诚信网站时代
  6. python对PDF文件操作
  7. 将Ubuntu系统安装到移动硬盘上,打造一个随身携带,即插即用的操作系统
  8. Nginx静态资源部署
  9. wordpress 网站百度不收录是什么原因
  10. windows文件设置标签