{"id":109,"date":"2020-01-22T19:43:36","date_gmt":"2020-01-22T19:43:36","guid":{"rendered":"https:\/\/ni.cmu.edu\/computing\/?post_type=ht_kb&#038;p=109"},"modified":"2020-01-22T19:43:36","modified_gmt":"2020-01-22T19:43:36","slug":"python","status":"publish","type":"ht_kb","link":"https:\/\/ni.cmu.edu\/computing\/knowledge-base\/python\/","title":{"rendered":"Python"},"content":{"rendered":"<p>This page needs updated!<\/p>\n<p>&nbsp;<\/p>\n<p>Python is installed on the cluster for users. There are many packages that extend Python\u2019s standard functionality. While we try to satisfy all requests for specific Python packages, we may not be able to meet your needs for various reasons. You can follow the directions below to help you install Python packages on your own.<\/p>\n<h3><a name=\"How_to_view_the_packages_that_ar\"><\/a> How to view the packages that are installed in python<\/h3>\n<p>You will find many common packages already installed:<\/p>\n<p>python27-extras module<br \/>\natlas-sse3\/atlas-sse3-devel<br \/>\nnumpy<br \/>\nscipy<br \/>\nnose<br \/>\nsphinx<br \/>\nPyDICOMM<br \/>\nnibabel<br \/>\nscikit-learn<br \/>\nstatsmodels<br \/>\nmne<\/p>\n<p>To see a full list of packages you can run python and use the following command: <code>&gt;&gt;&gt; help(\"modules\")<\/code><\/p>\n<h3><a name=\"How_to_run_Python_in_interactive\"><\/a> How to run Python in interactive mode<\/h3>\n<p>If you want to use Python interactively, then you would want to request an interactive pbs job and load the appropriate modules.:<\/p>\n<pre><code>[&lt;username@headnode&gt; ~]$ qsub -I -X -l nodes=1:ppn=1\r\nqsub: waiting for job &lt;some job name&gt; to start \r\nqsub: job &lt;some job name&gt; ready \r\n[&lt;username@compute node&gt; ~]$\r\n[&lt;username@compute node&gt; ~]$ module load python27 \r\n[&lt;username@compute node&gt; ~]$ module load python27-extras\r\n\r\n<\/code><\/pre>\n<h3><a name=\"How_to_run_Python_in_pbs_batch_j\"><\/a> How to run Python in pbs batch job<\/h3>\n<p>th<\/p>\n<h3><a name=\"How_to_install_packages_locally\"><\/a> How to install packages locally<\/h3>\n<p><code>easy_install<\/code> is a tool that automatically searches for your package at pypi.org, an online repository, downloads the files, and then installs them for you. To install packages in the default location, <code>easy_install<\/code> requires you to have special permissions. Fortunately, there are several ways to control the default location, and <code>--user<\/code> is the easiest option (run <code>easy_install --help<\/code> to see the others). For example, this is how one might install <code>&lt;package name&gt; <\/code>in their home directory:<\/p>\n<pre><code>[&lt;username@headnode&gt; ~]$ qsub -I -X -l nodes=1:ppn=1\r\nqsub: waiting for job &lt;some job name&gt; to start \r\nqsub: job &lt;some job name&gt; ready \r\n[&lt;username@compute node&gt; ~]$\r\n[&lt;username@compute node&gt; ~]$ module load python27 \r\n[&lt;username@compute node&gt; ~]$ module load python27-extras\r\n<\/code><\/pre>\n<pre><code>[&lt;username@compute node&gt; ~]$ easy_install --user &lt;package name&gt;<\/code><\/pre>\n<p>With this command, <code>&lt;package name&gt;<\/code>is installed to <code>~\/.local\/lib\/python2.7\/site-packages<\/code>, which is a directory Python automatically looks for when loading Python packages. If you have the package source code, and you want to install the package using its <code>setup.py<\/code> script, then you can use this flag as well:<\/p>\n<pre><code>[&lt;username@compute node&gt; ~]$ python setup.py build\r\n[&lt;username@compute node&gt; ~]$ python setup.py install --user<\/code><\/pre>\n<p>If your package installs scripts, then you will want to load the module <code>python_modules\/local<\/code>, which simply prepends <code>$HOME\/.local\/bin<\/code> to your <code>PATH<\/code> environment variable. In other words, it tells the shell\/terminal where to look for your scripts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This page needs updated! &nbsp; Python is installed on the cluster for users. There are many packages that extend Python\u2019s standard functionality. While we try to satisfy all requests for specific Python packages, we may not be able to meet your needs for various reasons. You can follow the directions&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[11],"ht-kb-tag":[],"class_list":["post-109","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-software"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":1,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/109\/revisions"}],"predecessor-version":[{"id":110,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/109\/revisions\/110"}],"wp:attachment":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb-category?post=109"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb-tag?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}