{"id":1430,"date":"2017-05-12T11:52:06","date_gmt":"2017-05-12T15:52:06","guid":{"rendered":"http:\/\/localhost:8280\/?p=1430"},"modified":"2022-07-01T11:18:04","modified_gmt":"2022-07-01T15:18:04","slug":"python","status":"publish","type":"post","link":"https:\/\/knowledgebasev.kinsta.cloud\/?p=1430","title":{"rendered":"Python"},"content":{"rendered":"<p>Python is preinstalled on all clusters. You must install your own packages. Not every package is installed (see below). You must run a <a href=\"https:\/\/knowledgebasev.kinsta.cloud\/?p=233\">batch or interactive job<\/a> to run python jobs.<\/p>\n<h3>Installing Python Packages<\/h3>\n<p>You must install your own packages. Not every package is preinstalled on the system. You can install specific python packages in your account. You must install from an interactive job using pip.<\/p>\n<p>For example:<\/p>\n<p>First start an interactive job using at least one core:<\/p>\n<pre>qsub -I -l nodes=1:ppn=1<\/pre>\n<p>List the available base python versions.<\/p>\n<pre>module avail python<\/pre>\n<p>Next, load the python module matching the version you require.<\/p>\n<pre>module load python\/3.9.5<\/pre>\n<p>Use pip to install the setup tools first. The tool will allow you to install a package. You only have to install the tool once.<\/p>\n<pre>pip install -U --user setuptools<\/pre>\n<p>Lastly, install your package. You may want to use the &#8216;&#8211;no-deps&#8217; option.<\/p>\n<pre>pip install -U --user &lt;package_name&gt;<\/pre>\n<p>Exit the interactive job when finished to halt charges.<\/p>\n<p>Your package is now installed in your account (in .local\/lib\/python\/site-packages\/). You only have to install the package once. You can now use it for any job from any compute node.<\/p>\n<h3>Interactive Python job<\/h3>\n<p>First start an interactive job. In this example, we are using 1 copper node and 24 cores.<\/p>\n<pre>qsub -I -l nodes=1:copper:ppn=24<\/pre>\n<p>Next, load the python module matching the version you require.<\/p>\n<pre>module load python\/3.9.5<\/pre>\n<p>Run your script<\/p>\n<pre>python3 run.py<\/pre>\n<p>Exit the interactive job when finished to halt charges.<\/p>\n<pre>exit<\/pre>\n<h3>Python job in batch mode example<\/h3>\n<p>Below is a simple python pbs script. This script will run python in batch using a &#8216;copper&#8217; node and 16 cores. Note: &#8220;python3&#8221; must be used. There is a bug where the alias\u00a0&#8220;python&#8221; -&gt; &#8220;python3&#8221; will not work with batch jobs. Be sure to install any packages you may need prior to running the batch job.<\/p>\n<pre>#PBS -l nodes=1:copper:ppn=16\r\ncd $PBS_O_WORKDIR\r\nmodule load python\/3.9.3\r\npython3 run.py<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Python is preinstalled on all clusters. You must install your own packages. Not every package is installed (see below). You must run a batch or interactive job to run python jobs. Installing Python Packages You must install your own packages. Not every package is preinstalled on the system. You can install specific python packages in [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85],"tags":[181,36,164,163,180],"class_list":["post-1430","post","type-post","status-publish","format-standard","hentry","category-software-specific-guides","tag-install","tag-packages","tag-pip","tag-python","tag-python3"],"_links":{"self":[{"href":"https:\/\/knowledgebasev.kinsta.cloud\/index.php?rest_route=\/wp\/v2\/posts\/1430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/knowledgebasev.kinsta.cloud\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/knowledgebasev.kinsta.cloud\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/knowledgebasev.kinsta.cloud\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/knowledgebasev.kinsta.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1430"}],"version-history":[{"count":9,"href":"https:\/\/knowledgebasev.kinsta.cloud\/index.php?rest_route=\/wp\/v2\/posts\/1430\/revisions"}],"predecessor-version":[{"id":1852,"href":"https:\/\/knowledgebasev.kinsta.cloud\/index.php?rest_route=\/wp\/v2\/posts\/1430\/revisions\/1852"}],"wp:attachment":[{"href":"https:\/\/knowledgebasev.kinsta.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/knowledgebasev.kinsta.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/knowledgebasev.kinsta.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}