other:python:starting
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
other:python:starting [2019/04/26 14:20] – [Initialization] jypeter | other:python:starting [2021/09/22 15:32] – [CDAT] Updated info jypeter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Working with Python ====== | ====== Working with Python ====== | ||
- | <note tip>This page will tell you how to select a python distribution and start (and exit!) the python interpreter | + | <note tip>This page will tell you how to select a //python distribution// and start (and exit!) the python interpreter |
- | You can then read the [[jyp_steps|JYP' | + | After reading this page, you can read the [[jyp_steps|JYP' |
</ | </ | ||
Line 12: | Line 12: | ||
In order to start working with Python, you need to have a //Python distribution// | In order to start working with Python, you need to have a //Python distribution// | ||
- | If you are using a Linux computer or a Mac, you should already have a **default python** installed. The following example shows where the python interpreter is installed on the //obelix// LSCE servers (if it's in ''/ | + | If you are using a Linux computer or a Mac, you should already have a **default python** installed. The following example shows where the python interpreter is installed on the //obelix// LSCE servers (if it's in ''/ |
< | < | ||
Line 34: | Line 34: | ||
==== Initialization ==== | ==== Initialization ==== | ||
- | - Start a terminal on an //obelix// server | + | - Start a terminal on an //obelix// server |
- | - Type '' | + | - Type '' |
- | - Determine if you are using a [[other: | + | - ...or **follow the steps below to use the more complete //CDAT// distribution |
+ | - Determine if you are using a [[other: | ||
* In a //bash// shell: '' | * In a //bash// shell: '' | ||
* In a //tcsh// shell: '' | * In a //tcsh// shell: '' | ||
- | - Choose which //flavor// of Python you want by typing: | + | - Choose which //flavor// of Python you want by typing |
* Python 2.7.x: '' | * Python 2.7.x: '' | ||
* Python 3.x: '' | * Python 3.x: '' | ||
- Type '' | - Type '' | ||
+ | - Note: if you will have to use python regularly, you should add the '' | ||
+ | * **Do not** add the '' | ||
+ | |||
+ | === Example === | ||
+ | |||
+ | < | ||
+ | Last login: Mon Jun 3 08:49:53 2019 from somewhere | ||
+ | bash-4.2$ which python | ||
+ | / | ||
+ | bash-4.2$ source ~jypeter/ | ||
+ | bash-4.2$ which python | ||
+ | / | ||
+ | bash-4.2$ conda activate cdatm_py2 | ||
+ | (cdatm_py2) bash-4.2$ which python | ||
+ | / | ||
+ | (cdatm_py2) bash-4.2$ python | ||
+ | Python 2.7.15 | packaged by conda-forge | (default, Feb 28 2019, 04:00:11) | ||
+ | [GCC 7.3.0] on linux2 | ||
+ | Type " | ||
+ | >>> | ||
+ | hello! | ||
+ | >>> | ||
+ | </ | ||
==== Useful keyboard shortcuts ==== | ==== Useful keyboard shortcuts ==== | ||
Line 103: | Line 127: | ||
This section will help you choose a distribution in the big Python ecosystem (many distributions, | This section will help you choose a distribution in the big Python ecosystem (many distributions, | ||
- | Only install a distribution yourself if you need it on your local computer (desktop or laptop), or if you need to install some modules that can't be installed by the contacts listed below. A python distribution will require several Gb of disk space, so do not install it in a backed up //home// directory! | + | Only install a distribution yourself if you need it on your local computer (desktop or laptop), or if you need to install some modules that can't be installed by the contacts listed below. A python distribution will require several Gb of disk space, so do not install it in your backed up //home// directory! |
You can use either //Python 2// or //Python 3//. Most packages are now available in both versions, but you should make sure that the most important package/s you need is/are available in the selected Python version. You can check the [[https:// | You can use either //Python 2// or //Python 3//. Most packages are now available in both versions, but you should make sure that the most important package/s you need is/are available in the selected Python version. You can check the [[https:// | ||
Line 110: | Line 134: | ||
* Contact: the LSCE system administrators ([[help-lsce@lsce.ipsl.fr]]) | * Contact: the LSCE system administrators ([[help-lsce@lsce.ipsl.fr]]) | ||
- | * Where: //obelix// interactive servers and cluster at LSCE | + | * Where: //obelix// interactive servers and // |
* Initialization type: [[other: | * Initialization type: [[other: | ||
* What's installed: type '' | * What's installed: type '' | ||
Line 131: | Line 155: | ||
Python 2.7.15 |Anaconda, Inc.| (default, Oct 10 2018, 21:32:13) | Python 2.7.15 |Anaconda, Inc.| (default, Oct 10 2018, 21:32:13) | ||
[GCC 7.3.0] on linux2 | [GCC 7.3.0] on linux2 | ||
- | Type " | ||
- | >>> | ||
- | </ | ||
- | |||
- | ==== TGCC distribution ==== | ||
- | |||
- | * Contact: the TGCC hotline ([[hotline.tgcc@cea.fr]]) | ||
- | * Where: CEA TGCC | ||
- | * Initialization type: [[other: | ||
- | * What's installed: it depends... | ||
- | |||
- | < | ||
- | $ module avail -t -d | egrep ' | ||
- | flavor/ | ||
- | flavor/ | ||
- | flavor/ | ||
- | flavor/ | ||
- | intelpython2/ | ||
- | intelpython3/ | ||
- | python/ | ||
- | python3/ | ||
- | cdat/ | ||
- | |||
- | $ module load python | ||
- | [...] | ||
- | load module python/ | ||
- | |||
- | $ which python | ||
- | / | ||
- | |||
- | $ python | ||
- | Python 2.7.14 (default, Jan 11 2018, 16:43:59) | ||
- | [GCC 4.8.5] on linux2 | ||
Type " | Type " | ||
>>> | >>> | ||
Line 170: | Line 161: | ||
==== CDAT ==== | ==== CDAT ==== | ||
- | [[https://uvcdat.llnl.gov/ | + | [[https://cdat.llnl.gov/ |
CDAT is **available for Mac, Linux and Windows 10 (Windows 10 + [[other: | CDAT is **available for Mac, Linux and Windows 10 (Windows 10 + [[other: | ||
Line 184: | Line 175: | ||
^ CDAT version | ^ CDAT version | ||
- | | **8.1** | + | | **8.2.1** |
+ | | **8.1** | ||
+ | |||
+ | == Initialization == | ||
+ | |||
+ | Read the [[https:// | ||
+ | |||
+ | Note: on the ciclad cluster, use '' | ||
=== CDAT at TGCC === | === CDAT at TGCC === | ||
+ | |||
+ | Note: TGCC also supports its own [[# | ||
CDAT **8.0** is installed at TGCC and can be initialized with: | CDAT **8.0** is installed at TGCC and can be initialized with: | ||
Line 192: | Line 192: | ||
* Python 3: '' | * Python 3: '' | ||
- | === The basics of CDAT initialization | + | === A common |
- | + | ||
- | The way you initialize CDAT depends on: | + | |
- | * which **server** you want to use it on | + | |
- | * which **shell** you are using in your terminals: //tcsh// or other shells | + | |
- | * Read [[other: | + | |
- | * Warning: the shell in a (batch) script may be different from your interactive shell! | + | |
- | * which **version** of CDAT you want to use... | + | |
Note: if you get an error when importing //cdms2// or //vcs// it means that either you have forgotten to initialize CDAT, or that something went wrong during the initialization. In both cases, you are either still using the default python installed on your system, or another (non-CDAT) python distribution! | Note: if you get an error when importing //cdms2// or //vcs// it means that either you have forgotten to initialize CDAT, or that something went wrong during the initialization. In both cases, you are either still using the default python installed on your system, or another (non-CDAT) python distribution! | ||
Line 212: | Line 205: | ||
/ | / | ||
- | === conda-based versions of CDAT === | + | ==== TGCC distribution ==== |
- | <WRAP center round important 60%> | + | * Contact: the TGCC hotline ([[hotline.tgcc@cea.fr]]) |
- | \\ The steps detailed in this section are for [[other:uvcdat: | + | * Where: CEA TGCC |
- | </ | + | * Initialization type: [[other:newppl:starting# |
+ | * What's installed: it depends... | ||
- | Note: if you need to maintain a **local** | + | < |
+ | $ module avail -t -d | egrep ' | ||
+ | flavor/ | ||
+ | flavor/ | ||
+ | flavor/ | ||
+ | flavor/ | ||
+ | intelpython2/ | ||
+ | intelpython3/ | ||
+ | python/ | ||
+ | python3/ | ||
+ | cdat/8.0(default) | ||
- | == Configuring | + | $ module load python |
+ | [...] | ||
+ | load module python/ | ||
- | You should **add** the following line at the end of your '' | + | $ which python |
+ | /ccc/ | ||
- | ^ Server | + | $ python |
- | | **LSCE** | + | Python 2.7.14 (default, Jan 11 2018, 16:43:59) |
- | | **ciclad** | + | [GCC 4.8.5] on linux2 |
+ | Type " | ||
+ | >>> | ||
+ | </code> | ||
- | Note: when you add the specified line to your '' | + | ==== Anaconda ==== |
- | == Initializing CDAT == | + | <note tip>This is the recommended Python distribution/ |
- | <WRAP center round tip 60%> | + | [[https://www.continuum.io/why-anaconda|Anaconda]] is a distribution provided by [[https:// |
- | When you initialize CDAT, it will be available only in the **current** window/shell. In the other windows, you still get whatever your default python is. This should minimize potential side-effects | + | |
- | </WRAP> | + | |
- | - If [[other: | ||
- | * You can later go back to your previous shell by typing | + | Note: Anaconda provides and uses '' |
- | - Activate | + | |
- | * '' | + | |
- | * Use the table below to determine which environments are available on which server | + | |
- | - Use CDAT ! | + | |
- | ^ UV-CDAT version | + | ==== Enthought Deployment Manager |
- | | [[: | + | |
- | | [[: | + | |
- | | **cdatm** will always point to the latest stable version | + | |
- | | //latest stable version// | + | |
+ | <note tip>This was previously called //Enthought Python Distribution (EPD)// and then //Enthought Canopy//</ | ||
+ | [[https:// | ||
- | ==== Canopy ==== | + | There are native installers for Windows (.msi), Mac OS X (.pkg), RHEL/Fedora (.rpm), and Debian/Ubuntu (.deb) |
- | + | ||
- | [[https:// | + | |
- | + | ||
- | Canopy is **available for Windows, Mac and Linux**. You can download the free //Canopy Express// that will already provide many extensions. If you are entitled to use //Canopy Academic//, login from inside Canopy Express | + | |
- | + | ||
- | + | ||
- | ==== Anaconda ==== | + | |
- | + | ||
- | [[https://www.continuum.io/ | + | |
- | + | ||
- | Anaconda is **available for Windows, Mac and Linux** | + | |
- | + | ||
- | Note: Anaconda provides and uses '' | + | |
===== ipython ===== | ===== ipython ===== | ||
Line 272: | Line 260: | ||
==== ipython interpreter ==== | ==== ipython interpreter ==== | ||
- | The //ipython// interpreter provides more options and commands than the standard python interpreter, | + | The //ipython// interpreter provides more options and commands than the standard python interpreter, |
Starting ipython: '' | Starting ipython: '' | ||
Line 280: | Line 268: | ||
==== ipython notebook ==== | ==== ipython notebook ==== | ||
+ | |||
+ | <note warning> | ||
+ | |||
+ | [[https:// | ||
The ipython notebook is a way to interact with python (and other supported interpreted languages) inside a web browser. You can mix //cells// with python commands, cells with the output of the python commands (possibly graphics generated by the commands), and text (using some wiki-like rich text format). This interactive web page, aka notebook, can be saved in a '' | The ipython notebook is a way to interact with python (and other supported interpreted languages) inside a web browser. You can mix //cells// with python commands, cells with the output of the python commands (possibly graphics generated by the commands), and text (using some wiki-like rich text format). This interactive web page, aka notebook, can be saved in a '' |
other/python/starting.txt · Last modified: 2025/07/03 16:18 by jypeter