Python Development Environment Setup¶
These are the instructions for installing and configuring software to provide the best script development environment for Sutron Satlink 3 and XLink 500.
These instructions should only be followed if you plan on developing Python code. If all you wish to do is to load an existing Python script into the station, please see the following page: Loading a script and setup into Satlink 3 and XLink 500
Light weight Python coding may be done without installing the development environment. Please see Writing Measurement Scripts
The instructions are geared for a Windows PC. However, Sutron Python development may be done on other platforms too.
1. LinkComm¶
LinkComm is the program used to communicate with Satlink 3 and XLink 500. It sends Python scripts to Satlink 3 and XLink 500, configures the setup to invoke them, and it can test them as well. LinkComm also integrates into PyCharm, allowing a one-click script send and test.
Download LinkComm for Windows: https://www.otthydromet.com/en/p-sutron-linkcomm-software/LINKCOMM LinkComm also runs on iOS and Android: https://www.otthydromet.com/en/p-sutron-linkcomm-software/LINKCOMM
2. Git¶
Python source code examples are hosted on GitHub.
Git is version control software. It plugs nicely into PyCharm, simplifies installation, and allows for contribution to the Sutron Python GitHub project.
While you may download those examples through your browser, if you are planning on developing Python code, you really should get Git software.
2.1 Please choose one:¶
- Either install Git or download the examples
A. Either Install Git¶
- Download Git for Windows: https://git-scm.com/download/win
- Install Git
- Use default options
B. Or Download Examples¶
- Go to https://github.com/SutronPyto/LinkPython
- Download the example files (click Clone or download and choose Download ZIP)
- Extract the downloaded files to a folder of your choice (e.g. “C:\pyto”)
3. Python¶
Python is freely available. It is required to run Python code on your PC.
- Download https://www.python.org/downloads/
- The latest version of Python is likely fine. We developed with 3.5.
- Run the executable downloaded from python.org
- Make sure to check the “Add Python to Path” option
- Choose Install Now
- If your computer requires administrative privileges to install programs, you may need to do a custom install and make sure to check box to install for all users.
You may verify installation is good and OS environment is setup by opening a command window (CMD) and typing in “python” and enter. You should see 3 arrow prompt show up indicating python is running. You can press Ctrl+Z to exit out of the python prompt.
4. PyCharm¶
PyCharm is an integrated development environment that makes it easier to code in Python.
- PyCharm may be used to write and debug Python code.- PyCharm may also be used to load Python scripts into Satlink.- PyCharm features Git integration, making it easy to access the example code and contribute to the Python libraries.
4.1 Install¶
- Download PyCharm from:Make sure to get the free community version.
- Run the downloaded file and complete PyCharm install with default options
3A. If you have installed Git, hook into the Sutron Python project on GitHub
- Run PyCharm- Choose Check out from Version Control -> Git- For the URL, paste in https://github.com/SutronPyto/LinkPython- For the Directory, choose any local folder- Click Clone- At this point, the source code has been downloaded onto your PC.
3B. If you have downloaded the examples onto your computer (e.g. in “C:\pyto”):
4.2 Settings¶
- Go to PyCharm -> File -> Settings -> Project -> Project Interpreter- Check that the Python Interpreter says Python 3- The folders must be marked as source.- Go to PyCharm -> File -> Settings -> Project -> Project Structure- Right click pc folder and mark it as source- Do the same for the src folder
4.3 Verification¶
5. Configure PyCharm to use LinkComm¶
The steps below will guide you through setting up LinkComm as an External Tool in PyCharm. Doing these steps will allow you to run your scripts on Satlink 3 and XLink 500 directly from PyCharm. This will also allow you to easily debug your code since any errors reported by Satlink 3 and XLink 500 will be turned into hyperlinks that jump directly to the line containing the error in your code.
5.1 Script load and test¶
"C:\Program Files (x86)\Sutron\LinkComm\LinkComm.exe"
--scripttest $FilePath$
$FILE_PATH$, line $LINE$
5.2 Script save¶
One more external tool needs to be created for saving scripts.
--scriptsave
5.3 Test out the connection to LinkComm¶
Now, if you go to PyCharm -> Tools -> External Tools, you will see two new options:
- “Script load and test” - this will send the currently open python file to Satlink 3 and XLink 500 and test it out.
- “Script save” - this will permanently save the file last sent to Satlink 3 and XLink 500