Installation of Python and Jupyter

Installation of Python and Jupyter

Gromacs Gromacs

Learning goals:

  • To be able to install and verify software

  • Install and start Python and Jupyter

Keywords: Python, Anaconda, conda, pip, Project Jupyter, Jupyter Lab, Jupyter Notebook, package conflict

Note: Since Python and Jupyter are core components of the course, it is imperative that the installation works.

Associated material:

We will install Python 3. The previous version, Python 2, has been officially deprecated and it is no longer maintained.

While Python 3 and Python 2 are compatible to a large extent, there are differences and incompatibilities. This should be kept in mind especially when searching for information from the net or when using books that provide examples in Python 2.

Installation

There are two main options:

  1. Anaconda (or Conda)-based installation and

  2. pip (Python Package Installer).

Both are good choices but there are differences. Conda installation gives immediately a very large number of packages including the most relevant ones needed in this course. It is a very convenient choice and the preferred one here. Anaconda has a both a graphical user interface as well as command line (conda). In addition, both Jupyter Lab and Jupyter Notebook are installed automatically with Anaconda. Pip, however, gets new packages usually faster but all packages must be separately installed and there is no graphical user interface. This also means that Jupyter must be installed separately. With pip one also has to be more careful with package conflicts and it is generally a good idea to use so called virtual environment to avoid problems.

In brief, Anaconda is easier. In addition to Python, Jupyter Notebook and Lab will be installed immediately. Anaconda is available for Windows 10, MacOS and Linux. Pip may be your choice if you have already experience with Python but Anaconda is recommended for the current purposes.

Note regarding Windows vs WSL/WSL2: The Anaconda installer works great in Windows and it also works in WSL/WSL2 through the Linux installation process. It may be more convenient to use the Anaconda installer in Windows, although that is a matter of personal choice. In addition, WSL/WSL2 have a basic Python installation present (not the full Anaconda distribution, though) in case needed.

Note regarding Mac: Older Macs come with Python 2, but is no longer the case since MacOS Catalina. Independent of Python is present, the Anaconda installation is recommended.

Keep Python up-to-date

Updating all packages is very easy,

conda update --all

To update conda:

conda update conda

Install packages:

conda install <package name>

Virtual environments

Important

Install and use Python virtual environments. That is very helpful and also helps to avoid potential package conflicts upon updates.