{"id":148412,"date":"2023-10-20T10:47:55","date_gmt":"2023-10-20T14:47:55","guid":{"rendered":"http:\/\/www.bu.edu\/tech\/?page_id=148412"},"modified":"2025-08-27T13:06:27","modified_gmt":"2025-08-27T17:06:27","slug":"conda","status":"publish","type":"page","link":"https:\/\/www.bu.edu\/tech\/support\/research\/software-and-programming\/common-languages\/python\/python-installs\/conda\/","title":{"rendered":"Installs with Conda"},"content":{"rendered":"<p><a name=\"top\"><\/a><br \/>\n<strong>Sections<\/strong><\/p>\n<ul>\n<li><a href=\"#using\">Using Conda Environments<\/a>\n<ul>\n<li><a href=\"#create\">Create Environment<\/a><\/li>\n<li><a href=\"#activate\">Activate Environment<\/a><\/li>\n<li><a href=\"#install\">Install Packages in Environment<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#moving-conda-env\">Installing and Distributing Conda Environments<\/a><\/li>\n<li>\n<ul>\n<li><a href=\"#installyml\">Install from YAML<\/a><\/li>\n<li><a href=\"#exportyml\">Export to YAML<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><a name=\"using\"><\/a><\/p>\n<h2>Using Conda Environments<\/h2>\n<p><a name=\"create\"><\/a><\/p>\n<div style=\"margin-left: 20px;\">\n<h3>Create Environment<\/h3>\n<p>After loading a Miniconda module version for the first time and <a href=\"https:\/\/www.bu.edu\/tech\/support\/research\/software-and-programming\/common-languages\/python\/python-software\/miniconda-modules\/#Conda%20Modules\">configuring your <code>.condarc<\/code><\/a> file, create a new conda environment named <code><b>my_conda_env<\/b><\/code> in your <code>\/projectnb<\/code> space. We recommend use of the <code><b>mamba<\/b><\/code> command for superior speed than the traditional <code>conda<\/code> command when creating environments. Note that mamba and conda will create a completely empty environment, so we are installing Python version 3.10 in the example below.<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">module load miniconda<\/span>\r\n<span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">mamba create -y -n <\/span><span class=\"placeholder\">my_conda_env<\/span> <span class=\"command\">python=3.10<\/span>\r\n<span class=\"output\">...\r\nPreparing transaction: done\r\nVerifying transaction: done\r\nExecuting transaction: done<\/span><\/code><\/pre>\n<p><strong>If you plan to use a Jupyter notebook<\/strong> or Jupyter Lab\u00a0 or Spyder for your code development, you need to install <em>notebook<\/em>, <em>jupyterlab<\/em>, or <em>spyder<\/em> packages, respectively:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">module load miniconda<\/span>\r\n<span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">mamba create -y -n <\/span><span class=\"placeholder\">my_conda_env<\/span> <span class=\"command\">python=3.10 notebook<\/span>\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p><a name=\"activate\"><\/a><\/p>\n<div style=\"margin-left: 20px;\">\n<h3>Activate Environment<\/h3>\n<p>Activate <code><b>my_conda_env<\/b><\/code>. Note that once activated, the command prompt begins with <code>(my_conda_env)<\/code> signifying you are inside the conda environment.<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">mamba activate<\/span> <span class=\"placeholder\">my_conda_env<\/span>\r\n<span class=\"prompt\">(my_conda_env) [rcs@scc1 ~]<\/span>\r\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p><a name=\"install\"><\/a><\/p>\n<div style=\"margin-left: 20px;\">\n<h3>Install Packages in Environment<\/h3>\n<p>To add packages released via conda channels, use <code><b>mamba install<\/b><\/code>. For packages released only though PyPI, use <code><b>pip install<\/b><\/code>.<\/p>\n<div style=\"margin-left: 20px;\">\n<h4>Conda Packages<\/h4>\n<pre><code class=\"code-block\"><span class=\"prompt\">(my_conda_env) [rcs@scc1 ~]<\/span> <span class=\"command\">mamba install -y -c conda-forge spyder<\/span>\r\n<span class=\"output\">...\r\nPreparing transaction: done                                                     \r\nVerifying transaction: done                                                     \r\nExecuting transaction: done <\/span><span class=\"output\"><\/span><\/code><\/pre>\n<p>In the above example, we installed <a href=\"https:\/\/anaconda.org\/conda-forge\/spyder\">Spyder<\/a> from the <code>conda-forge<\/code> channel. There are many other conda channels such as <code>bioconda<\/code>, <code>anaconda<\/code>, or <code>defaults<\/code>.<\/p>\n<h4>PyPI Packages<\/h4>\n<pre><code class=\"code-block\"><span class=\"prompt\">(my_conda_env) [rcs@scc1 ~]<\/span> <span class=\"command\">pip install htseq<\/span>\r\n<span class=\"output\">...\r\nInstalling collected packages: pysam, numpy, htseq\r\nSuccessfully installed htseq-2.0.4 numpy-1.26.1 pysam-0.22.0<\/span><\/code><\/pre>\n<p>In the above example, we installed <a href=\"https:\/\/htseq.readthedocs.io\/en\/latest\/\">HTSeq<\/a> into <code><b>my_conda_env<\/b><\/code> same as done within Python.<\/p>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p><a name=\"moving-conda-env\"><\/a><\/p>\n<h2>Installing and Distributing Conda Environments<\/h2>\n<p>Software are often distributed as conda environments through use of <a href=\"https:\/\/docs.conda.io\/projects\/conda\/en\/latest\/user-guide\/tasks\/manage-environments.html?highlight=yml#create-env-file-manually\">YAML configuration files<\/a>.<\/p>\n<div style=\"margin-left: 20px;\">\n<p><a name=\"installyml\"><\/a><\/p>\n<h3>Install from YAML<\/h3>\n<p>Here is an example of creating a conda environment from a YAML file. With the <code>-n name<\/code> argument an environment will be created in the location specified in your <code>.condarc<\/code> file. The <code>-p \/path\/to\/new\/env<\/code> flag can be used to place the environment in a specific location. The conda tool is recommended over mamba when exporting environments:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">conda env create -n polymer_env -f environment.yml<\/span><\/code><\/pre>\n<p>In the above example, we installed <a href=\"https:\/\/github.com\/hygeos\/polymer\">Polymer<\/a> from the distributed YAML file.<\/p>\n<p><a name=\"exportyml\"><\/a><\/p>\n<h3>Export to YAML<\/h3>\n<p>Here is how you export an activated conda environment to a YAML format file:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">(my_conda_env) [rcs@scc1 ~]<\/span> <span class=\"command\">conda env export -f environment.yml<\/span><\/code><\/pre>\n<p>This creates a YAML file with the conda and PyPI packages listed with the version and a build specification for each one. To export an environment with just the versions listed add the <code>--no-builds<\/code> flag. This can be helpful if you want to move an environment between operating systems, such as re-creating a conda enviroment from the SCC on a Mac OSX laptop:<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">(my_conda_env) [rcs@scc1 ~]<\/span> <span class=\"command\">mamba env export --no-builds -f environment.yml<\/span><\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"#top\">Back to top<\/a><\/p>\n<div style=\"float: right;\">\n<p id=\"last-modified-timestamp\" style=\"margin: 0;\">Last updated: Loading&#8230;<\/p>\n<\/div>\n<p><script>\r\ndocument.addEventListener('DOMContentLoaded', function() {\r\n    \/\/ Get the content of the meta tag\r\n    var lastUpdatedContent = document.querySelector('meta[name=\"last-updated\"]').content;\r\n    \r\n    \/\/ Parse the content into a Date object\r\n    var lastUpdatedDate = new Date(lastUpdatedContent);\r\n    \r\n    \/\/ Format the date\r\n    var formattedDate = lastUpdatedDate.toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' });\r\n    \r\n    \/\/ Update the HTML element with the formatted date\r\n    document.getElementById('last-modified-timestamp').innerHTML = 'Last updated: ' + formattedDate;\r\n});\r\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sections Using Conda Environments Create Environment Activate Environment Install Packages in Environment Installing and Distributing Conda Environments Install from YAML Export to YAML &nbsp; Using Conda Environments Create Environment After loading a Miniconda module version for the first time and configuring your .condarc file, create a new conda environment named my_conda_env in your \/projectnb space&#8230;.<\/p>\n","protected":false},"author":1692,"featured_media":0,"parent":147620,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/148412"}],"collection":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/users\/1692"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/comments?post=148412"}],"version-history":[{"count":45,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/148412\/revisions"}],"predecessor-version":[{"id":159339,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/148412\/revisions\/159339"}],"up":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/147620"}],"wp:attachment":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/media?parent=148412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}