Design with Python¶
Writing protocols in Python requires some up-front design before seeing your liquid handling automation in action. At a high-level, writing protocols with the Opentrons API looks like:
- Write a Python protocol
- Test the code for errors
- Repeat steps 1 & 2
- Calibrate labware on robot
- Run your protocol
These sets of documents aim to help you get the most out of steps 1 & 2, the “design” stage.
Python for Beginners¶
If Python is new to you, we suggest going through a few simple tutorials to acquire a base understanding to build upon. The following tutorials are a great starting point for working with the Opentrons API (from learnpython.org):
After going through the above tutorials, you should have enough of an understanding of Python to work with the Opentrons API and start designing your experiments!
Working with Python¶
Currently, we recommend writing your protocols in one of two ways:
Using a popular and free code editor, like Sublime Text 3, is a common method for writing Python protocols. Download onto your computer, and you can now write and save Python scripts.
Make sure that when saving a protocol file, it ends with the
.py file extension. This will ensure the App and other programs are able to properly read it.
For a more interactive environment to write and debug using some of our API tools, we recommend using Jupyter Notebook. To begin, just install Anaconda, which comes with Jupyter Notebook.
Once installed, launch Jupyter Notebook, and install the Opentrons API by doing the following:
- Create a new Python notebook
- Run the command
!pip install --upgrade opentronsin a cell
- Restart your notebook’s Kernel, and API will be installed
Be sure to download the Python 3.6 version if Anaconda, and Python 2.7 will not work with the Opentrons API.