Just to try to give a more concrete example, if you want to write a Python script to control the stage, the most annoying part is often setting up the Python environment in the first place. This varies depending on which operating system you use, and how your computer is configured.
The first step is ensuring you have a suitable version of Python. Anything from Python 3.7 to Python 3.10 should work OK for
sangaboard I think. If you open a command prompt (PowerShell is what I use on Windows, or a bash shell on Linux) and type
python --version hopefully it will give you a version number in that range. If it starts with a 2, try
python3 --version instead - some systems still use
python3 instead of
python for version 3. If you don’t have Python 3 installed, there are many ways to get it. Most often, I just install Python and then worry about packages later. Others doing science are keen on using Anaconda to manage their Python environments, though I always find it a bit confusing.
Once you have a working version of Python installed, you should make yourself a new folder to work in. Inside that folder, you should create a “virtual environment” to let you install all the Python modules you need, without messing up your system’s Python installation. This stops the work you’re doing with OpenFlexure from messing up other applications or projects on your computer. You can do this by typing:
python -m venv .venv --prompt OFM
This will create a folder called
.venv in the current folder, and put in a basic installation of Python.
You should now “activate” your new environment. On Windows, you type
On Linux you need to run
After that, you should see
[OFM] appear at the start of each line in the console. That means your virtual environment is installed and active. You can now start installing the packages, e.g.
pip install sangaboard
Now, you should be able to start Python and issue interactive commands:
That should put you into a Python command prompt
sb = sangaboard.SangaBoard("COM1")
"COM1" should be replaced with the name of the serial port you are using. If you leave it empty, i.e.
SangaBoard() it will try to autodetect, which may or may not work depending on how many ports you have and what’s plugged in.
The commands above will do a relative move by 1000 steps in X, then print the position, then exit the Python interpreter.
I hope that explains a bit better how to get something basic working!