{"id":791,"date":"2018-11-12T16:44:33","date_gmt":"2018-11-12T16:44:33","guid":{"rendered":"http:\/\/ri.itservices.manchester.ac.uk\/csf3\/?page_id=791"},"modified":"2026-02-16T12:58:06","modified_gmt":"2026-02-16T12:58:06","slug":"anaconda-python","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/software\/applications\/anaconda-python\/","title":{"rendered":"Anaconda Python"},"content":{"rendered":"<p><script type=\"text\/javascript\">\n    function toggle() {\n        var x = document.getElementById(\"hidetext\");\n        if (x.style.display === \"none\") {x.style.display = \"block\";}\n        else {x.style.display = \"none\";}\n    }\n<\/script><\/p>\n<div class=\"warning\">\n<p>We recommend using <a href=\"\/csf3\/software\/applications\/conda\/\">Miniforge3<\/a> for managing Conda environments, installing Python, and other packages distributed with Conda.<\/p>\n<p>To display the legacy Anaconda information, <a href=\"javascript:toggle()\">click here<\/a>\n<\/div>\n<div id=\"hidetext\" style=\"display: none\">\n<h2>Overview<\/h2>\n<p><a href=\"https:\/\/www.anaconda.com\/\">Anaconda<\/a> is a completely free enterprise-ready Python distribution for large-scale data processing, predictive analytics, and scientific computing general-purpose statistical software package. It contains 100+ of the most popular Python packages for science, math, engineering, data analysis. <\/p>\n<p>Versions available are listed below in &#8216;Set up Procedure&#8217;.<\/p>\n<h2>Restrictions on use<\/h2>\n<p>There are no restrictions on access Anaconda Python on the CSF. All users should read the <a href=\"http:\/\/docs.continuum.io\/anaconda\/eula.html\">End User License Agreement<\/a> before using the software.<\/p>\n<h2>Set up procedure<\/h2>\n<p>We now recommend loading modulefiles within your jobscript so that you have a full record of how the job was run. See the example jobscript below for how to do this. Alternatively, you may load modulefiles on the login node and let the job inherit these settings.<\/p>\n<p>Load one of the following modulefiles (most recent listed at the top, oldest at the bottom):<\/p>\n<pre>\r\nmodule load apps\/binapps\/anaconda3\/2024.10  # Python 3.12.7\r\nmodule load apps\/binapps\/anaconda3\/2023.09  # Python 3.11.5\r\nmodule load apps\/binapps\/anaconda3\/2023.03  # Python 3.10.10\r\nmodule load apps\/binapps\/anaconda3\/2022.10  # Python 3.9.13\r\nmodule load apps\/binapps\/anaconda3\/2021.11  # Python 3.9.7\r\nmodule load apps\/python\/miniconda3\/4.10.3   # Python 3.9.5\r\nmodule load apps\/binapps\/anaconda3\/2020.07  # Python 3.8.3\r\nmodule load apps\/binapps\/anaconda3\/2019.07  # Python 3.7.3\r\nmodule load apps\/binapps\/anaconda3\/2019.03  # Python 3.7.3\r\n\r\n# The following versions are old and no longer supported.\r\n# Modulefiles for other applications may still use them if needed.\r\n# But we recommend that you <strong>DO NOT load these directly<\/strong> - instead\r\n# you should upgrade to one of the above versions.\r\n# If you really need to use these old versions, please first load:\r\nmodule load apps\/csfold\r\nmodule load apps\/anaconda3\/5.2.0            # Python 3.6.5\r\nmodule load apps\/anaconda\/2.5.0             # Python 2.7.15\r\n<\/pre>\n<h2>Additional Centrally Installed Packages<\/h2>\n<p>The following packages have been centrally installed so are available by default.<\/p>\n<p>If a package listed under a previous version is not listed in a newer version it is because it would not install or it was not compatible with or it was not available for the later version of Anaconda python at the time of central install. If you require a package, please try installing it yourself in a <a href=\"#condaenv\">conda environment<\/a>.<\/p>\n<p>To check whether a package is available, try the <code>conda list<\/code> command. For example:<\/p>\n<pre>\r\nmodule load apps\/binapps\/anaconda3\/2023.09\r\nconda list pandas\r\n# packages in environment at <strong>\/opt\/apps\/apps\/binapps\/anaconda3\/2023.09<\/strong>:\r\n#\r\n# Name                    Version                   Build  Channel\r\npandas                    2.0.3           py311ha02d727_0\r\n  #\r\n  # pandas is included in Anaconda python, so you can use the following in your code:\r\n  # import pandas;\r\n<\/pre>\n<p>The <code>\/opt\/apps\/apps\/binapps\/anaconda3\/2023.09<\/code> environment is the central install of Anaconda. If you&#8217;ve activated your own conda environment (see below) then it will list what&#8217;s available in your env.<\/p>\n<h3>apps\/binapps\/anaconda3\/2022.10 packages<\/h3>\n<p>None.<\/p>\n<h3>apps\/binapps\/anaconda3\/2021.11 packages<\/h3>\n<ul>\n<li>PyMC3<\/li>\n<li>r-irkernel<\/li>\n<li>r-essentials<\/li>\n<li>textblob<\/li>\n<li>docopt<\/li>\n<li>biopython<\/li>\n<\/ul>\n<h3>apps\/binapps\/anaconda3\/2020.07 packages<\/h3>\n<ul>\n<li>PyMC3<\/li>\n<li>r-irkernel<\/li>\n<li>r-essentials<\/li>\n<li>textblob<\/li>\n<li>docopt<\/li>\n<li>biopython<\/li>\n<li>matam<\/li>\n<\/ul>\n<h3>apps\/binapps\/anaconda3\/2019.03 packages<\/h3>\n<ul>\n<li>PyMC3<\/li>\n<li>r-irkernel<\/li>\n<li>r-essentials<\/li>\n<li>rpy2<\/li>\n<li>textblob<\/li>\n<li>docopt<\/li>\n<li>biopython<\/li>\n<\/ul>\n<h3>apps\/anaconda3\/5.2.0 packages<\/h3>\n<ul>\n<li>PyMC3<\/li>\n<li>pyPcazip (version 2.0.8)<\/li>\n<li>r-irkernel<\/li>\n<li>r-essentials<\/li>\n<li>rpy2<\/li>\n<li>textblob<\/li>\n<\/ul>\n<h3>apps\/anaconda\/2.5.0 packages<\/h3>\n<ul>\n<li>pyPcazip (version 1.5.1)<\/li>\n<\/ul>\n<h2>Running the application<\/h2>\n<p>Please do not run python on the login node. Jobs should be submitted to the compute nodes via batch. If you wish to do interactive development with python, please start an <a href=\"\/csf3\/batch\/qrsh\/\">interactive session<\/a> first.<\/p>\n<h3>Serial batch job submission<\/h3>\n<p>Before submitting the job we will write the following simple python script for use as an example:<\/p>\n<pre># fib-example.py\r\nparents, babies = (1, 1)\r\nwhile babies &lt; 100:\r\n    print 'This generation has %d babies' % babies\r\n    parents, babies = (babies, parents + babies)\r\n<\/pre>\n<p>Now create a batch submission script that we will submit to the batch system:<\/p>\n<pre class=\"slurm\">\r\n#!\/bin\/bash --login\r\n#SBATCH -p serial\r\n#SBATCH -t 0-1       # 1 hour wallclock time limit (max permitted is 7-0, i.e. 7 days)\r\n\r\n# Load the version you require\r\nmodule load apps\/binapps\/anaconda3\/2022.10\r\n\r\n# Execute our simple python script we created above:\r\npython <em>fib-example.py<\/em>\r\n<\/pre>\n<p>Submit the jobscript using:<\/p>\n<pre>sbatch <em>scriptname<\/em><\/pre>\n<p>where <em>scriptname<\/em> is the name of your jobscript.<\/p>\n<h3>Parallel batch job submission<\/h3>\n<p>A simple parallel <code>numpy<\/code> example script is:<\/p>\n<pre># eig-example.py\r\nimport numpy\r\n\r\ndef test_eigenvalue():\r\n  i=500\r\n  data=numpy.random.rand(i,i)\r\n  result=numpy.linalg.eig(data)\r\n  return result\r\n\r\nprint(test_eigenvalue())\r\n<\/pre>\n<p>and the corresponding jobscript is:<\/p>\n<pre class=\"slurm\">\r\n#!\/bin\/bash --login\r\n#SBATCH -p multicore  # Partition is required. Runs on an AMD Genoa hardware.\r\n#SBATCH -n numcores   # (or --ntasks=) where numcores is between 2 and 168.\r\n#SBATCH -t 4-0        # Wallclock limit (days-hours). Required!\r\n                      # Max permitted is 7 days (7-0).\r\n\r\n# Load the version you require\r\nmodule load apps\/binapps\/anaconda3\/2022.10\r\n\r\n# Inform numpy how many cores to use. $SLURM_NTASKS is automatically set to the number given above.\r\nexport OMP_NUM_THREADS=$SLURM_NTASKS\r\n\r\npython <em>eig-example.py<\/em>\r\n<\/pre>\n<h3>Using a Conda Env in a batch job<\/h3>\n<p>If you have created your own conda environment, usually in which to install packages (see <a href=\"#condaenv\">below<\/a> for details on how to do this), you must <em>activate<\/em> the conda environment in your jobscript so that it can find your python packages. Create a jobscript similar to the following (note that this is a serial, one core, jobscript but you could use a parallel jobscript if your software supports the use of multiple cores):<\/p>\n<pre class=\"slurm\">\r\n#!\/bin\/bash --login\r\n#SBATCH -p serial  # Partition is required. Runs on an Intel hardware.\r\n                   # Or submit batch jobs to the \"interactive\" partition for AMD Genoa serial jobs.\r\n#SBATCH -t 4-0     # Wallclock limit (days-hours). Required!\r\n                   # Max permitted is 7 days (7-0).\r\n\r\n# Load the version you require\r\nmodule load apps\/binapps\/anaconda3\/2022.10\r\n\r\n# Activate the environment. Note: You <strong>must<\/strong> use the 'source' keyword, not 'conda'.\r\nsource activate <em>my_env<\/em>\r\n\r\n# Python now has access to any packages installed in your conda env\r\npython <em>my_app.py<\/em>\r\n\r\n# You can deactivate the environment at the end of the batch job, although this\r\n# step is optional if you are not running any more commands in your jobscript.\r\nsource deactivate\r\n<\/pre>\n<p>Submit the jobscript using:<\/p>\n<pre class=\"slurm\">sbatch <em>scriptname<\/em><\/pre>\n<p>where <em>scriptname<\/em> is the name of your jobscript.<\/p>\n<h2>Adding packages<\/h2>\n<div class=\"warning\">\nJune 2023: The proxy is <strong>no longer available<\/strong>.<br \/>\nCSF (Slurm) &#8211; You can download and install packages from external source while on the login node.\n<\/div>\n<h3>Anaconda packages<\/h3>\n<p>To see what is already installed (in the central anaconda installation):<\/p>\n<pre>conda list\r\n<\/pre>\n<p>To see if a package is available<\/p>\n<pre>conda list <em>package<\/em>\r\n<\/pre>\n<p>where <em><code>package<\/code><\/em> is replaced with the name of the package you want. If the package you require is listed as available for install, read on for how you can install packages in your own <em>home<\/em> directory storage using <em>conda environments<\/em> or <code>pip<\/code>.<\/p>\n<p><a name=\"condaenv\"><\/a><\/p>\n<h3>Conda environments<\/h3>\n<p>A conda <em>environment<\/em> provides a localised installation of packages managed by Anaconda python. Multiple environments can be set up for different groups of packages or projects (e.g., a <em>machine learning<\/em> project and a different <em>chemsitry<\/em> project). Use a new conda environment for each project so that you don&#8217;t break previous projects when you install other packages. The packages are installed in a directory in your home area.<\/p>\n<p>The following commands will install and activate \/ deactivate a particular environment.<\/p>\n<p><strong>Before using conda environments, load the required anaconda modulefile <del datetime=\"2024-10-03T09:51:45+00:00\">and proxy<\/del><\/strong>. Run these commands in an interactive session or submit as a batch job to set up a new conda environment:<\/p>\n<pre>\r\n# CSF (Slurm) - you can just do this on the login node\r\n\r\n# <strong>Carry on from here:<\/strong>\r\nmodule load apps\/binapps\/anaconda3\/2022.10      # Load the version <em>you<\/em> require\r\n\r\n# You should stay on the compute node while you create and add packages to\r\n# your conda env. Once you are happy with it, you can 'exit' the compute node\r\n# (run 'exit') to return to the login node. Jobscripts can use your new\r\n# conda environment (see below.) If you need to install any more packages in\r\n# the env, start with the 'qrsh' command as above.\r\n<\/pre>\n<h3>Create a new new conda environment<\/h3>\n<p>Now create the conda environment. You will then be able to add conda (python) packages to it.<\/p>\n<p>For reference, packages will be stored in your home dir in a directory specific to each conda environment you create: <code>~\/.conda\/envs\/<em>envname<\/em><\/code>. But you shouldn&#8217;t need to use this path directly &#8211; the conda commands will ensure packages are installed and used from this area.<\/p>\n<p>There are a couple of ways you can create a conda environment which we&#8217;ll now go through (we use the name <code>test_env<\/code> in the examples below).<\/p>\n<ol>\n<li>Method 1: create a new environment that contains various standard packages such as <code>pip<\/code>, <code>setuptools<\/code> nad <code>python<\/code> etc (it will tell you what is being installed). These help you install other packages (e.g., using the <code>pip<\/code>, which you might see in the installation instructions of a github project.) You can specify a particular version of python (to match the centrally installed version) or conda will download the latest available and install that in your environment:\n<pre>\r\n# If you want to ensure you use the same version of python as in the central install:\r\npython --version\r\n    #\r\n    # Make a note of: <strong>3.9.13<\/strong> (or whatever your version is)\r\n\r\n# Create the conda environment (remove the ==3.9.13 to use the latest version of python)\r\nconda create -y -n <strong>test_env<\/strong> python==<strong>3.9.13<\/strong>\r\n\r\n<\/pre>\n<p>You can ignore any messages about new versions of conda and upgrading them.<\/li>\n<li>Method 2: Alternatively, if you just need an empty environment you can create an empty environment then add packages to it later:\n<pre>conda create -y -n <strong>test_env<\/strong>\r\n<\/pre>\n<p>You can ignore any messages about new versions of conda and upgrading them.<\/li>\n<\/ol>\n<p>In both of the above examples, you can add the name of a python package to be installed while creating your environment. For example:<\/p>\n<pre>conda create -y -n test_env <em>packagename<\/em>\r\n<\/pre>\n<h3>Activate the new new conda environment<\/h3>\n<p>You <em>must<\/em> activate the conda environment after creating it, so that further package installs go inside your new environment.<\/p>\n<p>The following commands should be used in a jobscript or interactive session <em>every time<\/em> you want to use your conda environment.<\/p>\n<p><strong>Note<\/strong>: that we <strong>DO NOT USE<\/strong> <code>conda activate <em>envname<\/em><\/code>. Instead <strong>WE USE<\/strong> <code>source activate <em>envname<\/em><\/code>. See <a href=\"#activate\">below for info on conda activate vs source activate<\/a>.<\/p>\n<pre>\r\n# Activate virtual env - these commands can be run inside a jobscript or an interactive session\r\nsource activate <strong>test_env<\/strong>        # We <strong>do not<\/strong> recommend 'conda activate ...'\r\n\r\n# If you are on the login node you'll see your prompt change to indicate you\r\n# are working in an activated conda environement:\r\n(<strong>test_env<\/strong>) [<em>username<\/em>@login2 [csf3] ~]$\r\n   #\r\n   # The name of your active conda env is displayed at the prompt\r\n<\/pre>\n<h3>Adding and removing a package to\/from your conda environment<\/h3>\n<p>Using the previously activated environment (you <em>must<\/em> activate the env!):<\/p>\n<pre>\r\n# <strong>(Optional) You can test whether a package is available by doing<\/strong>:\r\npython -c \"import <em>packagename<\/em>\"\r\n  #\r\n  # If you see no output then <em>packagename<\/em> is already installed.\r\n  # If you see an error, you need to install <em>packagename<\/em> in your env.\r\n\r\n# <strong>If you wanted to install packages in the current active env<\/strong>:\r\nconda install -y <em>packagename<\/em>\r\n\r\n# Can now run your python script using the packages installed in your environment:\r\npython <em>myscript.py<\/em>\r\n\r\n# <strong>If you wanted to remove a package from the current active env<\/strong>:\r\nconda remove -y <em>packagename<\/em>\r\n\r\n# When you are finished, switch off the conda environment.\r\n# Your python code will only have access to the packages provided by the central install.\r\nsource deactivate\r\n\r\n# The login node prompt will now return to normal (no env name displayed)\r\n[<em>username<\/em>@login2 [csf3] ~]$\r\n<\/pre>\n<p>You&#8217;ve now successfully created a conda environment and installed some packages in to it.<\/p>\n<div class=\"hint\">We highly recommend keeping a list of the <code>conda install ...<\/code> commands run when creating an environment and populating it with various packages. While it is possible to export to YAML file the contents of a conda environment, it is sometimes easier to simply re-run all of the <code>conda install ...<\/code> commands should you ever need to recreate a conda env elsewhere.<\/div>\n<p>Some other actions you may wish to perform with your environments:<\/p>\n<h3>List your conda environments<\/h3>\n<pre># Get a list of all your conda environments (active env shown with a *)\r\nconda env list\r\n   # conda environments:\r\n   #\r\n   gputest                  &lt;HOME&gt;\/.conda\/envs\/gputest\r\n   my_bioinf_env            &lt;HOME&gt;\/.conda\/envs\/my_bioinf_env\r\n   base                  *  \/opt\/apps\/apps\/binapps\/anaconda3\/2022.10\r\n<\/pre>\n<h3>List the packages installed in the active conda env<\/h3>\n<pre># Get a list of the packages installed in the currently active environment\r\nconda list\r\n<\/pre>\n<h3>Install packages in another named conda env<\/h3>\n<pre># Install other packages in a named virtual env (for example we install a packed named pillow).\r\n# If you don't specify the name it will install in the currently active package.\r\nconda install -y -n test_env pillow\r\n<\/pre>\n<h3>Remove (delete) a conda env<\/h3>\n<pre># To remove the test_env virtual env files (deletes files from your ~\/.conda\/envs\/ directory)\r\nconda remove -y -n test_env --all\r\n<\/pre>\n<h3>Activate other Channels in a conda env<\/h3>\n<p>It is possible to activate other <em>channels<\/em> inside a conda environment so that you can install packages from different channels. For example, to use <a href=\"https:\/\/bioconda.github.io\/\">BioConda<\/a> in a conda env:<\/p>\n<pre>\r\n# This example uses the BioConda channel and installs a package named emirge from that channel.\r\n\r\n# CSF (Slurm) - you can just install this from the login node\r\n\r\n# <strong>Carry on from here:<\/strong>\r\n# note that emirge requires python 2.7 so we use the older Anaconda v2 installation:\r\nmodule load apps\/anaconda\/2.5.0         # Provides Python 2.7.15\r\n\r\n# Create a new conda env\r\nconda create -y -n my_bioinf_env python==2.7.15\r\n   #\r\n   # (ignore warning about new version of conda)\r\n   # \r\n   # \r\n   # Proceed ([y]\/n)? <strong>y<\/strong>\r\n\r\n# Activate the environment\r\nsource activate my_bioinf_env             # Can also use 'conda activate my_bioinf_env'\r\n\r\n# Add the BioConda channels to the env - these are the places where packages\r\n# are downloaded from. The BioConda website says the order of these is important.\r\nconda config --env --add channels defaults\r\nconda config --env --add channels bioconda\r\nconda config --env --add channels conda-forge\r\n\r\n# Install the emirge package (use your own packages here)\r\nconda install emirge\r\n\r\n# We use emirge at the command-line but you may need to run python\r\n# and import a library, for example.\r\nemirge.py --help\r\n\r\n# Deactivate the env when done\r\nsource deactivate\r\n\r\n# Go back to the login node\r\nexit\r\n<\/pre>\n<h3>pip installation inside a conda env<\/h3>\n<p>The above section showed how to create a conda env and then use the <code>conda install<\/code> command to install packages in to that environment.<\/p>\n<p>You may also want to perform <code>pip<\/code> installations in to your conda env. This is possible but you need to perform a couple of extra steps:<\/p>\n<pre>\r\n# CSF (Slurm) - you can install packages from external source on the login node\r\n\r\n# <strong>Carry on from here:<\/strong>\r\n# First move a config file you may have out of the way. If this is present it\r\n# will force the pip install to occur outside of the conda env.\r\n# For new versions of pip you can instead add the <strong>--isolated<\/strong> flag to the pip\r\n# command to ask it to ignore this file.\r\nmv ~\/.pydistutils.cfg ~\/.pydistutils.cfg.ignore\r\n\r\n# Now load which ever version of python you need. For example:\r\nmodule load apps\/binapps\/anaconda3\/2022.10\r\n\r\n# Check which version of python we have. We'll force the conda env to use that version.\r\npython --version\r\n    # Make a note of: 3.9.13\r\n\r\n# Create the conda env containing some basic python packages, including 'pip'.\r\n# It is important to use the 'pip' package installed inside your conda env so\r\n# that it knows to install pypi packages inside the env.\r\nconda create -y -n <strong>myenv<\/strong> python==3.9.13\r\n[y]\r\n\r\n# <strong>YOU MUST DO THIS BEFORE YOU CAN INSTALL IN TO THE ENV: Activate the env<\/strong>\r\nsource activate <strong>myenv<\/strong>\r\n\r\n# Now install your pip package(s) - note NO --user flag here so that the\r\n# packages are installed inside the conda env's directory.\r\npip install <strong>--isolated<\/strong> --log pip.log <em>packagename<\/em>\r\n #             #\r\n #             # New versions of pip accept an --isolated flag to make them\r\n #             # ignore any ~\/.pydistutils.cfg file you may have. It is\r\n #             # You must either remove the ~\/.pydistutils.cfg file or use\r\n #             # the --isolated flag on the pip command otherwise the packages\r\n #             # will NOT be installed in your conda env!\r\n #\r\n\r\n# You should now be able to use your pypi package:\r\npython\r\nimport <em>packagename<\/em>\r\n<\/pre>\n<h3>pip\/pypi installation (outside of a conda env)<\/h3>\n<p>An alternative to using conda environments is to install a package in to your home area using <code>pip<\/code>. This will make the package available every time you run python, but makes it difficult to separate packages and dependencies for different tasks. The above conda environments method is recommended.<\/p>\n<p>To install a package in to your home directory storage area:<\/p>\n<pre># We are NOT using a conda env so here you should NOT be working in an active env\r\n[<em>username<\/em>@login2 [csf3] ~]$ pip install --user <em>package<\/em>\r\n<\/pre>\n<p>where <code>package<\/code> is replaced with the name of the package you want. This will install the package to a hidden directory called <code>.local<\/code> in your home directory.<\/p>\n<p>It should be automatically picked up by python when that module is loaded in the future, you can test thus:<\/p>\n<pre>python\r\nimport <em>package<\/em>\r\nhelp (<em>package<\/em>)\r\n<\/pre>\n<h3>Rebuild\/recreate an existing conda environment<\/h3>\n<p>If you ever need to recreate an existing conda environment, for instance to utilise upgraded system libraries please do the following. <\/p>\n<pre>\r\n# Load anaconda module file\r\nmodule load apps\/binapps\/anaconda3\/2024.10\r\n\r\n# Activate the environment you want to recreate\r\nconda activate <em>env_name<\/em>\r\n\r\n# Export Package Specs (includes both Conda and Pip packages)\r\nconda env export > ~\/full_env.yml\r\n\r\n# Edit .yml file using the text editor of your choice and change the name of environment.\r\nname: env_name   # Old name\r\n<em># Change to<\/em> \r\nname: new_env_name  # New name\r\n\r\n# Create conda environment\r\nconda env create -f ~\/full_env.yml\r\n\r\n# Deactivate old environemt and activate new one\r\nconda deactivate\r\nconda activate new_env_name\r\n\r\n<\/pre>\n<h2>Hints and Tips<\/h2>\n<p>Got a handy tip? Please <a href=\"\/csf3\/overview\/help\/\">send it in<\/a> and we&#8217;ll publish it here.<\/p>\n<p><a name=\"activate\"><\/a><\/p>\n<h3>conda activate vs source activate<\/h3>\n<p>After creating a new conda env (see above) and trying to activate it with:<\/p>\n<pre>conda create -y my_new_env\r\nconda activate my_new_env\r\n<\/pre>\n<p>you may see a message:<\/p>\n<pre>CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.\r\nTo initialize your shell, run\r\n    $ conda init \r\n\r\nCurrently supported shells are:\r\n  - bash\r\n...\r\n  - powershell\r\n\r\nSee 'conda init --help' for more information and options.\r\n\r\nIMPORTANT: You may need to close and restart your shell after running 'conda init'.\r\n<\/pre>\n<p>At this point, we recommend that you <strong>DO NOT<\/strong> run <code>conda init bash<\/code>. This will edit your <code>~\/.bashrc<\/code> script, which is run every time you log in to the CSF. It will add commands to automatically activate the <code>base<\/code> conda env upon login for the version of Anaconda python you are currently using. This can interfere with other applications, other version of Anaconda python, or other conda environments.<\/p>\n<p>You can tell whether you did at some point run <code>conda init bash<\/code> by looking at your login prompt:<\/p>\n<pre><strong>(base)<\/strong> [<em>username<\/em>@login1 [csf3] ~]$\r\n   #\r\n   # If you see \"<strong>(base)<\/strong>\" in your prompt after logging in to the CSF then\r\n   # you must have run 'conda init' at some point. This fixes the version of\r\n   # anaconda python in use, which will make using newer versions provided\r\n   # by our modulefiles more difficult.\r\n   # See below for how to edit your ~\/.bashrc file to remove this.\r\n<\/pre>\n<p>Instead, run:<\/p>\n<pre># Use this INSTEAD of 'conda init ...'\r\nsource activcate my_new_env\r\n<\/pre>\n<p>The <code>source<\/code> command will activate your environment without editing your <code>~\/.bashrc<\/code> file. You should also use <code>source activate my_new_env<\/code> in your jobscripts.<\/p>\n<h3>Undo changes made to your <code>~\/.bashrc<\/code> file<\/h3>\n<p>If you did run <code>conda init bash<\/code> then you can remove the following lines from your <code>~\/.bashrc<\/code> file (which is just a text file:<\/p>\n<pre>gedit ~\/.bashrc\r\n  #\r\n  # Remove everything bewteen the lines show below, including the two line!\r\n  # This occurs at the bottom of your ~\/.bashrc file.\r\n\r\n# &gt;&gt;&gt; conda initialize &gt;&gt;&gt;\r\n# !! Contents within this block are managed by 'conda init' !!\r\n\r\n... <em>remove all of the script code and these surrounding lines<\/em> ...\r\n\r\n# &lt;&lt;&lt; conda initialize &lt;&lt;&lt;\r\n<\/pre>\n<h3>Plotting graphs with Pyplot<\/h3>\n<p>If you want to plot a graph to a PNG file, say, in batch, try the following (see this <a href=\"http:\/\/stackoverflow.com\/questions\/4931376\/generating-matplotlib-graphs-without-a-running-x-server\">stackoverflow question and answer<\/a>):<\/p>\n<pre># Create a file named graph.py:\r\n\r\nimport matplotlib as mpl\r\n# Agg backend will render without X server on a compute node in batch\r\nmpl.use('Agg')\r\nimport matplotlib.pyplot as plt\r\n\r\nfig = plt.figure()\r\nax = fig.add_subplot(111)\r\nax.plot(range(10))\r\n# Save the graph to a .png file (you cannot use plt.show() in a batch job)\r\nfig.savefig('temp.png')\r\n<\/pre>\n<p>Then, to quickly test from the CSF login node, load the modulefile and submit a batch job (without writing a jobscript):<\/p>\n<pre>module load apps\/anaconda3\/5.2.0\r\nsrun -p interactive -t 10 --pty python .\/graph.py\r\n<\/pre>\n<p>When job completes, view the image file on the login node using the Linux <code>eog<\/code> tool:<\/p>\n<pre>eog temp.png\r\n<\/pre>\n<h2>Further info<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.anaconda.com\">Anaconda website<\/a><\/li>\n<\/ul>\n<h2>Updates<\/h2>\n<p>None.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We recommend using Miniforge3 for managing Conda environments, installing Python, and other packages distributed with Conda. To display the legacy Anaconda information, click here Overview Anaconda is a completely free enterprise-ready Python distribution for large-scale data processing, predictive analytics, and scientific computing general-purpose statistical software package. It contains 100+ of the most popular Python packages for science, math, engineering, data analysis. Versions available are listed below in &#8216;Set up Procedure&#8217;. Restrictions on use There are.. <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/software\/applications\/anaconda-python\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":86,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-791","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/comments?post=791"}],"version-history":[{"count":25,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/791\/revisions"}],"predecessor-version":[{"id":11869,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/791\/revisions\/11869"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/86"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/media?parent=791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}