<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://hpc.mediawiki.hull.ac.uk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=561978</id>
	<title>HPC - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://hpc.mediawiki.hull.ac.uk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=561978"/>
	<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/Special:Contributions/561978"/>
	<updated>2026-05-30T11:43:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2300</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2300"/>
		<updated>2018-03-02T16:02:01Z</updated>

		<summary type="html">&lt;p&gt;561978: 561978 moved page Python to Applications/Python without leaving a redirect&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a YAML File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a YAML file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the YAML called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a YAML File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a YAML file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
'''1.)'''   Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''2.)'''Export your active virtual environment using the following command&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env export &amp;gt; env.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2299</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2299"/>
		<updated>2018-03-02T16:00:59Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Exporting a Virtual Environment in Anaconda to a YAML File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a YAML File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a YAML file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the YAML called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a YAML File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a YAML file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
'''1.)'''   Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''2.)'''Export your active virtual environment using the following command&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env export &amp;gt; env.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2298</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2298"/>
		<updated>2018-03-02T16:00:38Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Creation of a Virtual Environment in Anaconda Using a YAML File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a YAML File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a YAML file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the YAML called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a YAML File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
'''1.)'''   Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''2.)'''Export your active virtual environment using the following command&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env export &amp;gt; env.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2297</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2297"/>
		<updated>2018-03-02T16:00:19Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Creation of a Virtual Environment in Anaconda Using a YAML File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a YAML File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a YAML file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a YAML File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
'''1.)'''   Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''2.)'''Export your active virtual environment using the following command&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env export &amp;gt; env.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2296</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2296"/>
		<updated>2018-03-02T15:59:50Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Exporting a Virtual Environment in Anaconda to a Yaml File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a YAML File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a YAML File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
'''1.)'''   Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''2.)'''Export your active virtual environment using the following command&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env export &amp;gt; env.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2295</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2295"/>
		<updated>2018-03-02T15:59:40Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Creation of a Virtual Environment in Anaconda Using a Yaml File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a YAML File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
'''1.)'''   Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''2.)'''Export your active virtual environment using the following command&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env export &amp;gt; env.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2294</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2294"/>
		<updated>2018-03-02T15:58:44Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Exporting a Virtual Environment in Anaconda to a Yaml File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
'''1.)'''   Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''2.)'''Export your active virtual environment using the following command&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env export &amp;gt; env.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2293</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2293"/>
		<updated>2018-03-02T15:58:29Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Exporting a Virtual Environment in Anaconda to a Yaml File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
'''1.)'''   Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''2.)''' 2.	Export your active virtual environment using the following command&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env export &amp;gt; env.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2292</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2292"/>
		<updated>2018-03-02T15:56:45Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Exporting a Virtual Environment in Anaconda to a Yaml File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
'''1.)'''   Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2291</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2291"/>
		<updated>2018-03-02T15:56:30Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Exporting a Virtual Environment in Anaconda to a Yaml File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
'''1.''' Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2290</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2290"/>
		<updated>2018-03-02T15:56:16Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Exporting a Virtual Environment in Anaconda to a Yaml File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
*1.* Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2289</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2289"/>
		<updated>2018-03-02T15:55:52Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Exporting a Virtual Environment in Anaconda to a Yaml File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
# Activate the Virtual environment you wish to export&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2288</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2288"/>
		<updated>2018-03-02T15:54:55Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Exporting a Virtual Environment in Anaconda to a Yaml File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
# Activate the Virtual environment you wish to export&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2287</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2287"/>
		<updated>2018-03-02T15:53:36Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Exporting a Virtual Environment in Anaconda to a Yaml File' */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== '''Exporting a Virtual Environment in Anaconda to a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2286</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2286"/>
		<updated>2018-03-02T15:53:23Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Creation of a Virtual Environment in Anaconda Using a Yaml File */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== ''Exporting a Virtual Environment in Anaconda to a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To export a virtual environment to a yaml file so that you or a third party can replicate your environment using Anaconda can be done using the following steps:&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2285</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2285"/>
		<updated>2018-03-02T14:26:11Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Environments ==&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2284</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2284"/>
		<updated>2018-03-02T14:25:19Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
==='''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of Virtual Environment Using Anaconda on Viper''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
=== '''Creation of a Virtual Environment in Anaconda Using a Yaml File''' ===&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2283</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2283"/>
		<updated>2018-03-02T14:22:36Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This above command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file called &amp;quot;myenv.yml&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2282</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2282"/>
		<updated>2018-03-02T14:19:01Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2281</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2281"/>
		<updated>2018-03-02T14:18:46Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
{{big|'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''}}&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2280</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2280"/>
		<updated>2018-03-02T14:18:04Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
{{big|'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper''}}'&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2279</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2279"/>
		<updated>2018-03-02T14:16:31Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2278</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2278"/>
		<updated>2018-03-02T14:11:21Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file.&lt;br /&gt;
&lt;br /&gt;
name: ytenv&lt;br /&gt;
channels:&lt;br /&gt;
- defaults&lt;br /&gt;
dependencies:&lt;br /&gt;
- ca-certificates=2017.08.26=h1d4fec5_0&lt;br /&gt;
- certifi=2018.1.18=py27_0&lt;br /&gt;
- intel-openmp=2018.0.0=hc7b2577_8&lt;br /&gt;
- libedit=3.1=heed3624_0&lt;br /&gt;
- libffi=3.2.1=hd88cf55_4&lt;br /&gt;
- libgcc-ng=7.2.0=h7cc24e2_2&lt;br /&gt;
- libgfortran-ng=7.2.0=h9f7466a_2&lt;br /&gt;
- libstdcxx-ng=7.2.0=h7a57d05_2&lt;br /&gt;
- mkl=2018.0.1=h19d6760_4&lt;br /&gt;
- ncurses=6.0=h9df7e31_2&lt;br /&gt;
- numpy=1.14.0=py27h3dfced4_1&lt;br /&gt;
- openssl=1.0.2n=hb7f436b_0&lt;br /&gt;
- pip=9.0.1=py27ha730c48_4&lt;br /&gt;
- python=2.7.14=h1571d57_29&lt;br /&gt;
- readline=7.0=ha6073c6_4&lt;br /&gt;
- setuptools=38.4.0=py27_0&lt;br /&gt;
- sqlite=3.22.0=h1bed415_0&lt;br /&gt;
- tk=8.6.7=hc745277_3&lt;br /&gt;
- wheel=0.30.0=py27h2bc6bb2_1&lt;br /&gt;
- zlib=1.2.11=ha838bed_2&lt;br /&gt;
- pip:&lt;br /&gt;
  - backports.functools-lru-cache==1.5&lt;br /&gt;
  - backports.shutil-get-terminal-size==1.0.0&lt;br /&gt;
  - cycler==0.10.0&lt;br /&gt;
  - decorator==4.2.1&lt;br /&gt;
  - enum34==1.1.6&lt;br /&gt;
  - h5py==2.7.1&lt;br /&gt;
  - ipython==5.5.0&lt;br /&gt;
  - ipython-genutils==0.2.0&lt;br /&gt;
  - matplotlib==2.1.2&lt;br /&gt;
  - mpmath==1.0.0&lt;br /&gt;
  - pathlib2==2.3.0&lt;br /&gt;
  - pexpect==4.4.0&lt;br /&gt;
  - pickleshare==0.7.4&lt;br /&gt;
  - prompt-toolkit==1.0.15&lt;br /&gt;
  - ptyprocess==0.5.2&lt;br /&gt;
  - pygments==2.2.0&lt;br /&gt;
  - pyparsing==2.2.0&lt;br /&gt;
  - python-dateutil==2.6.1&lt;br /&gt;
  - pytz==2018.3&lt;br /&gt;
  - scandir==1.7&lt;br /&gt;
  - simplegeneric==0.8.1&lt;br /&gt;
  - six==1.11.0&lt;br /&gt;
  - subprocess32==3.2.7&lt;br /&gt;
  - sympy==1.1.1&lt;br /&gt;
  - traitlets==4.3.2&lt;br /&gt;
  - wcwidth==0.1.7&lt;br /&gt;
  - yt==3.4.1&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2277</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2277"/>
		<updated>2018-03-02T14:10:43Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command is creating a virtual environment from the yaml called myenv.yml. Below is a copy of the mark-up contained within the file.&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2276</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2276"/>
		<updated>2018-03-02T14:10:19Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda env create -f myenv.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2275</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2275"/>
		<updated>2018-03-02T14:09:35Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2274</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2274"/>
		<updated>2018-03-02T14:09:16Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
To create a virtual environment from a yaml file you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2273</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2273"/>
		<updated>2018-03-02T14:08:52Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2272</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2272"/>
		<updated>2018-03-02T14:08:36Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
'''Creation of a Virtual Environment in Anaconda Using a Yaml File'''&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2271</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2271"/>
		<updated>2018-03-02T14:06:59Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2270</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2270"/>
		<updated>2018-03-02T14:06:09Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(newenv)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2269</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2269"/>
		<updated>2018-03-02T14:05:23Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On successful activation of this virtual environment you should the name of your environment in front of your login prompt like so:&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2268</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2268"/>
		<updated>2018-03-02T14:04:59Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2267</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2267"/>
		<updated>2018-03-02T14:04:11Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2266</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2266"/>
		<updated>2018-03-02T14:03:47Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ conda create –n newenv pip numpy&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above command creates a new virtual environment called newenv and installs pip and numpy within this environment.&lt;br /&gt;
&lt;br /&gt;
To activate this virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source activate newenv&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2265</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2265"/>
		<updated>2018-03-02T14:03:15Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2264</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2264"/>
		<updated>2018-03-02T13:56:38Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment using anaconda 4.1.1 with python version 2.7 on Viper,  you would use the conda create command as follows:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH=''&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2263</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2263"/>
		<updated>2018-03-02T13:54:59Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Anaconda on Viper'''&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2262</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2262"/>
		<updated>2018-03-02T13:54:04Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the python system packages. However because of the way viper is configured it will see python system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this environment variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2261</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2261"/>
		<updated>2018-03-02T13:50:56Z</updated>

		<summary type="html">&lt;p&gt;561978: 561978 moved page Applications/Python to Python without leaving a redirect&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the system python packages. However because of the way viper is configured it will see system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2260</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2260"/>
		<updated>2018-02-27T16:58:57Z</updated>

		<summary type="html">&lt;p&gt;561978: 561978 moved page Python to Applications/Python without leaving a redirect&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the system python packages. However because of the way viper is configured it will see system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2259</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2259"/>
		<updated>2018-02-27T16:55:14Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the system python packages. However because of the way viper is configured it will see system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To exit the virtual environment use the key combination '''ctrl + d'''&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2258</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2258"/>
		<updated>2018-02-27T16:54:00Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the system python packages. However because of the way viper is configured it will see system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If the environment starts correctly you should see the name of your environment in round brackets in front of the command prompt. For this particular example it should appear as follows:&lt;br /&gt;
   &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
(foo)  [user@c001 ~ ]$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2257</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2257"/>
		<updated>2018-02-27T16:51:36Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the system python packages. However because of the way viper is configured it will see system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo''' . To activate this virtual environment you would issue the following command:&lt;br /&gt;
 &amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ source foo/bin/activate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2256</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2256"/>
		<updated>2018-02-27T16:48:52Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the system python packages. However because of the way viper is configured it will see system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named '''foo'''&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2255</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2255"/>
		<updated>2018-02-27T16:48:37Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the system python packages. However because of the way viper is configured it will see system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This creates a directory containing your virtual environment named ''foo''&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2254</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2254"/>
		<updated>2018-02-27T16:47:28Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the system python packages. However because of the way viper is configured it will see system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2253</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2253"/>
		<updated>2018-02-27T16:47:05Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the system python packages. However because of the way viper is configured it will see system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this variable to empty as follows: ''export PYTHONPATH='' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2252</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2252"/>
		<updated>2018-02-27T16:42:54Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the system python packages. However because of the way viper is configured it will see system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this variable to empty as follows: [[export PYTHONPATH=']]'' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
	<entry>
		<id>https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2251</id>
		<title>Applications/Python</title>
		<link rel="alternate" type="text/html" href="https://hpc.mediawiki.hull.ac.uk/index.php?title=Applications/Python&amp;diff=2251"/>
		<updated>2018-02-27T16:42:21Z</updated>

		<summary type="html">&lt;p&gt;561978: /* Virtual Environments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
=== Application Details ===&lt;br /&gt;
* Description: Python is a high-level interpreted programming language for general-purpose programming, supported by a large number of libraries for many tasks&lt;br /&gt;
* Versions: Python 2.7.11 and 3.5.1&lt;br /&gt;
* Module names: python/2.7.11 python/3.5.1 &lt;br /&gt;
* License: Free to use - [https://en.wikipedia.org/wiki/Python_Software_Foundation_License Python Software Foundation License]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage Examples ==&lt;br /&gt;
&lt;br /&gt;
Python is provided by the [[applications/Anaconda|Anaconda package]] too&lt;br /&gt;
&lt;br /&gt;
=== Interactive ===&lt;br /&gt;
&lt;br /&gt;
Interactive with command line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ module add python/anaconda/4.0/2.7&lt;br /&gt;
[username@c170 ~]$ python&lt;br /&gt;
Python 2.7.5 (default, Nov 20 2015, 02:00:19)&lt;br /&gt;
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2&lt;br /&gt;
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Interactive with command line with IPython:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@c170 ~]$ ipython&lt;br /&gt;
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)&lt;br /&gt;
Type &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;
&lt;br /&gt;
IPython 5.1.0 -- An enhanced Interactive Python.&lt;br /&gt;
?         -&amp;gt; Introduction and overview of IPython's features.&lt;br /&gt;
%quickref -&amp;gt; Quick reference.&lt;br /&gt;
help      -&amp;gt; Python's own help system.&lt;br /&gt;
object?   -&amp;gt; Details about 'object', use 'object??' for extra details.&lt;br /&gt;
&lt;br /&gt;
In [1]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Batch Submission ===&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #C8C8C8; color: black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#SBATCH -J PythonTest                # Job name, you can change it to whatever you want&lt;br /&gt;
#SBATCH -N 1                                  # Number of nodes &lt;br /&gt;
#SBATCH --ntasks-per-node 1    # Number of cores per node&lt;br /&gt;
#SBATCH -o %N.%j.out                # Standard output will be written here&lt;br /&gt;
#SBATCH -e %N.%j.err                 # Standard error will be written here&lt;br /&gt;
#SBATCH -p compute                  # Slurm partition, where you want the job to be queued &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
module purge&lt;br /&gt;
module add python/3.5.1&lt;br /&gt;
 &lt;br /&gt;
python PythonTest.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is then submitted as follows:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[username@login01 ~]$ sbatch Pythontest.job&lt;br /&gt;
Submitted batch job 289522&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Virtual Environments ===&lt;br /&gt;
A Python Virtual Environment allows users to create a custom environment/s in which they can have the packages, and versions of said packages that they require without having to have elevated user privileges on the system. &lt;br /&gt;
&lt;br /&gt;
There are many benefits to using a virtual environment on a system. Here is a short non-exhaustive list of a few of the key benefits:&lt;br /&gt;
&lt;br /&gt;
* Control over packages and package versions&lt;br /&gt;
* An arbitrary number of virtual environments can be created for different tasks&lt;br /&gt;
* Reproducibility - A user can replicate a python environment on any system, so as to be able to run or re-run a particular task or job under the same conditions&lt;br /&gt;
&lt;br /&gt;
'''Creation of Virtual Environment Using Python 2.7.11 or 3.5.1 on Viper'''&lt;br /&gt;
&lt;br /&gt;
To create a virtual environment you would issue the following command:&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT NOTE: By default the virtual environment does not use the system python packages. However because of the way viper is configured it will see system packages because of the PYTHONPATH environment variable. So it is advised if you would like a clean environment (meaning no system packages being included) to set this variable to empty as follows: export PYTHONPATH=''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;&amp;quot;&amp;gt;&lt;br /&gt;
[user@c001 ~ ]$ virtualenv foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Further Information ==&lt;br /&gt;
* [https://www.hpc.hull.ac.uk/forum/viewforum.php?f=15 UoH Python forum] &lt;br /&gt;
* [[Programming/Python|Wiki: Python Programming]]&lt;br /&gt;
* [[Main Page#General_Support|Wiki: General Support]]&lt;br /&gt;
* [[Main Page|Wiki: Home]]&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;width:5%; border-width: 0&amp;quot; | [[File:icon_home.png]]&lt;br /&gt;
|style=&amp;quot;width:95%; border-width: 0&amp;quot; | &lt;br /&gt;
* [[Main_Page|Home]]&lt;br /&gt;
* [[Applications|Application support]]&lt;br /&gt;
* [[General|General]]&lt;br /&gt;
* [[Training|Training]]&lt;br /&gt;
* [[Programming|Programming support]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>561978</name></author>
		
	</entry>
</feed>