{"id":1302,"date":"2014-02-07T14:18:28","date_gmt":"2014-02-07T14:18:28","guid":{"rendered":"http:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/?page_id=1302"},"modified":"2019-01-28T15:52:08","modified_gmt":"2019-01-28T15:52:08","slug":"anaconda-python","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/software\/applications\/anaconda-python\/","title":{"rendered":"Anaconda Scientific Python Distribtuion"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>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 has 100+ of the most popular Python packages for science, math, engineering, data analysis.<\/p>\n<p>Versions 2.3.0, 2.1.0, 1.9.1 and 1.8.0 of Anaconda are installed on the CSF. These provide python 2.7.x.<\/p>\n<p>Version 5.1.0, 4.2.0, 4.1.1, and 2.3.0 of Anaconda3 is also installed. They provide Python 3.6.x, 3.5.x, and 3.4.x.<\/p>\n<p>To see what is available in these versions load the appropriate modulefile (see below) and then run the command:<\/p>\n<pre>\r\nconda list\r\n<\/pre>\n<p>Note: none of the python 2.6 or python 3.3 packages have been installed.<\/p>\n<h2>Restrictions on Use<\/h2>\n<p>None, but 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>Load <em>one<\/em> of the following modulefiles for the version you wish to use:<\/p>\n<h3>For Python 2.7.x<\/h3>\n<pre>\r\nmodule load apps\/binapps\/anaconda\/2.5.0\r\nmodule load apps\/binapps\/anaconda\/2.3.0\r\nmodule load apps\/binapps\/anaconda\/2.1.0\r\nmodule load apps\/binapps\/anaconda\/1.9.1\r\nmodule load apps\/binapps\/anaconda\/1.8.0\r\n<\/pre>\n<h3>For Python 3.4<\/h3>\n<pre>\r\n# Notice the extra \/3\/ in the modulefile name\r\n\r\nmodule load apps\/binapps\/anaconda\/3\/2.3.0\r\n<\/pre>\n<h3>For Python 3.5<\/h3>\n<pre>\r\n# Notice the extra \/3\/ in the modulefile name\r\n\r\nmodule load apps\/binapps\/anaconda\/3\/4.2.0\r\nmodule load apps\/binapps\/anaconda\/3\/4.1.1\r\n<\/pre>\n<h3>For Python 3.6<\/h3>\n<pre>\r\n# Notice the extra \/3\/ in the modulefile name\r\n\r\nmodule load apps\/binapps\/anaconda\/3\/5.1.0\r\n<\/pre>\n<h2>Running the application<\/h2>\n<p>After loading the modulefile you need to have a batch job submission script. Below are some examples.<\/p>\n<p><strong>Simple, Python-only job<\/strong><\/p>\n<p>Here is a simple Python script (download <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-content\/uploads\/fib.py\">fib.py<\/a>)<\/p>\n<pre>\r\nparents, babies = (1, 1)\r\nwhile babies < 100:\r\n    print 'This generation has %d babies' % babies\r\n    parents, babies = (babies, parents + babies)\r\n<\/pre>\n<p>This is an example SGE submission script (download <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-content\/uploads\/fib.sge\">fib.sge<\/a>)<\/p>\n<pre>\r\n#!\/bin\/bash\r\n#$ -S \/bin\/bash\r\n#$ -N Python_fib\r\n#$ -cwd\r\n#$ -o outputfile.log\r\n#$ -j y\r\n#$ -V\r\npython fib.py\r\n<\/pre>\n<p>Submit with the command<\/p>\n<pre>\r\nqsub fib.sge\r\n<\/pre>\n<p><strong>A numpy job<\/strong><\/p>\n<p>No extra SGE configuration is necessary in order to use modules such as numpy or scipy.  For example, to run the following script<\/p>\n<pre class=\"in1\">\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>you can use the following submission script, assuming that you've called the above script eig.py<\/p>\n<pre>\r\n#!\/bin\/bash\r\n#$ -S \/bin\/bash\r\n#$ -N Python_fib\r\n#$ -cwd\r\n#$ -o outputfile.log\r\n#$ -j y\r\n#$ -V\r\nexport OMP_NUM_THREADS=$NSLOTS        ### For serial jobs auto sets to 1 core. DO NOT set a number here.\r\n\r\npython eig.py\r\n<\/pre>\n<h2>Parallel Jobs - using more than one core<\/h2>\n<p>If you have some parallelism in your job (i.e. it has the ability to use more than 1 core) or you have used a package\/module which can use multiple cores you must request a number of cores from the <code>smp.pe<\/code> batch parallel environment and include the <code>OMP_NUM_THREADS<\/code> variable in your job to ensure that it uses the allocated resources correctly. Example:<\/p>\n<pre>\r\n#!\/bin\/bash\r\n#$ -S \/bin\/bash\r\n#$ -N Python_fib\r\n#$ -cwd\r\n#$ -o outputfile.log\r\n#$ -j y\r\n#$ -V\r\n#$ -pe smp.pe 4 ### Request 4 cores from the batch system. Min 2, max 24.\r\n\r\nexport OMP_NUM_THREADS=$NSLOTS   ## For parallel jobs auto sets to the no. on the pe line. DO NOT set a number here.\r\n\r\npython eig.py\r\n<\/pre>\n<h2>PyLab<\/h2>\n<p>If you wish to import NumPy, SciPy, Matplotlib and all in one easy step:<\/p>\n<pre>\r\nimport pylab\r\n<\/pre>\n<h2>Adding packages<\/h2>\n<p>You will need to set the following modulefile loading on the command line before proceeding:<\/p>\n<pre>\r\nmodule load tools\/env\/proxy\r\n<\/pre>\n<p>OR alternativey, set the following manually:<\/p>\n<pre>\r\nexport http_proxy=http:\/\/proxy.man.ac.uk:3128\r\nexport https_proxy=http:\/\/proxy.man.ac.uk:3128\r\n<\/pre>\n<h3>Anaconda packages<\/h3>\n<p>To see what is already installed:<\/p>\n<pre>\r\nconda list\r\n<\/pre>\n<p>To see if a package is available<\/p>\n<pre>\r\nconda list package\r\n<\/pre>\n<p>where <em><code>package<\/code><\/em> is replaced with the name of the package you want. If the package is listed as available for install please contact: <a href=\"&#x6d;a&#x69;&#108;&#x74;&#111;&#x3a;&#x69;t&#x73;&#45;&#x72;&#105;&#x2d;&#116;e&#x61;&#109;&#x40;&#109;&#x61;&#110;c&#x68;&#101;&#x73;&#116;&#x65;&#114;&#46;&#x61;c&#x2e;&#117;&#x6b;\">&#x69;&#x74;&#x73;&#x2d;&#x72;&#x69;&#x2d;&#x74;&#101;&#97;&#109;&#64;&#109;&#97;&#110;ches&#x74;&#x65;&#x72;&#x2e;&#x61;&#x63;&#x2e;&#x75;&#x6b;<\/a> and we will try to add it to the central installation.<\/p>\n<h3>pip\/pypi installation<\/h3>\n<p>To search for packages available to the <code>pip<\/code> installer:<\/p>\n<pre>\r\npip search <em>keyword<\/em>\r\n<\/pre>\n<p>To install a package within your home folder storage:<\/p>\n<pre>\r\npip 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. It should be automatically picked up by python, you can test thus:<\/p>\n<pre>\r\npython\r\nimport <em>package<\/em>\r\nhelp (<em>package<\/em>)\r\n<\/pre>\n<h2>Further information<\/h2>\n<ul>\n<li><a href=\"http:\/\/docs.continuum.io\/anaconda\/index.html\">Anaconda Python documentation, FAQ, mailing list etc<\/a><\/li>\n<li>IT Services runs an <a href=\"http:\/\/wiki.rac.manchester.ac.uk\/community\/Courses\">Introduction to numerical computing with Python<\/a> workshop approximately three times a year.<\/li>\n<\/ul>\n<h2>Hints and Tips<\/h2>\n<p>Got a handy tip? Please send it in to <a href=\"\">&#105;&#x74;&#115;&#x2d;r&#x69;-&#116;&#x65;&#97;&#x6d;&#64;&#x6d;a&#x6e;c&#104;&#x65;&#115;&#x74;e&#x72;&#46;&#x61;&#x63;&#46;&#x75;&#107;<\/a> ...<\/p>\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>\r\n# Create a file named graph.py:\r\n\r\nimport matplotlib as mpl\r\n# Agg backend wil 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\nfig.savefig('temp.png')\r\n# End of python file.\r\n\r\n# Tested on CSF using:\r\nmodule load apps\/binapps\/anaconda\/3\/2.3.0\r\nqsub -b y -cwd -V -l short python .\/graph.py\r\n\r\n# When job completes, view the graph\r\neog temp.png\r\n<\/pre>\n<h2>Updates<\/h2>\n<p>2.3.0 (Anaconda3) - installed 8th September 2015 - included docopt, biopython<br \/>\n2.3.0 - installed 8th July 2015 - included wxpython, docopt and MDAnalysis<br \/>\n2.1.0 - installed 27th Nov 2014 - included wxpython, docopt and MDAnalysis<br \/>\n1.9.1 - MDAnalysis installed via pip - Nov 2014<br \/>\n1.9.1 - docopt installed via pip - June 2014<br \/>\n1.9.1 - installed 27th Feb 2014 and wxpython added to it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 has 100+ of the most popular Python packages for science, math, engineering, data analysis. Versions 2.3.0, 2.1.0, 1.9.1 and 1.8.0 of Anaconda are installed on the CSF. These provide python 2.7.x. Version 5.1.0, 4.2.0, 4.1.1, and 2.3.0 of Anaconda3 is also installed. They provide Python 3.6.x, 3.5.x, and 3.4.x. To see what.. <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/software\/applications\/anaconda-python\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":31,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1302","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/pages\/1302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/comments?post=1302"}],"version-history":[{"count":20,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/pages\/1302\/revisions"}],"predecessor-version":[{"id":4979,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/pages\/1302\/revisions\/4979"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/pages\/31"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf-apps\/wp-json\/wp\/v2\/media?parent=1302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}