Getting started with Python
Installing Anaconda Distribution
Before you can install and use the iqcampy
package you need to prepare your computer by setting up a python environment in which you can execute python code and install additional python packages. It is recommended to do this by downloading (581MB) and installing Anaconda Distribution. For installation instructions on Windows, Mac and Linux see: https://docs.anaconda.com/anaconda/install/
Included are many powerful data science python packages, Jupyter notebooks and the python package manager program pip
. You are now ready to install additional packages such as iqcampy
.
Installing iqcampy
Take a look at the Python Package Index at https://pypi.org/ and search for the python package that you need. In our case iqcampy. Open a terminal window (in the Windows start menu called Anaconda Prompt) and type the installation command and press enter:
pip install iqcampy
This command starts the python package manager program pip
and tells it to fetch the package from the Python Package Index and install on your computer. You are now ready to run the code examples in a Jupyter notebook.
If at some point in the future you would like to upgrade iqcampy to a newer version, execute the pip command with the upgrade -U
flag:
pip install -U iqcampy
Run a Jupyter notebook
Jupyter notebooks are files with the filename extension .ipynb
. In the old days they were called interactive python notebooks, hence the extension. You can type and execute python code, and see the results, in these notebooks. Interaction with these notebooks works via a modern web browser such as Firefox or Chrome. I am not sure if other web browsers also work. To create and run a notebook you need to start a Jupyter Notebook server. On windows this is done by clicking on the Jupyter Notebook
item in the start menu. Alternatively, you can start a notebook server by typing this command in a terminal:
jupyter notebook
The Jupyter Notebook server should open in your browser on the dashboard page. Although we see stuff appearing in the web browser, all processes are happening locally on your computer. Now you can select the folder you want to work in and create a new notebook with the new
button.
Execute a code cell
The Jupyter ecosystem has expanded rapidly in the last years. I find this a bit confusing. So let’s stick with the classic python Jupyter Notebook for now.
Jupyter notebooks contain two types of cells: code cells and markdown cells. Try by typing 1 + 1
in a code cell. You can execute the code cell by simultaneously pressing Shift
and Enter
. More information is found in the help menu and on-line: https://jupyter.org/try.
That is it! You can now move on to the next sections and try the code examples.