Installation¶
Python Version¶
- Python 3.11 or 3.12 is recommended
- Python 3.13 and above currently can't install
pywebview(no available pythonnet wheel); the program falls back to opening the default browser automatically and still works fine, just without a native window
Setting up a dedicated virtual environment is recommended:
python3.11 -m venv venv
venv\Scripts\activate # Windows
Install Dependencies¶
pip install -r requirements.txt
(equivalent to pip install flask pyserial)
To use native window mode (optional, see "No-window mode" below), additionally install:
pip install pywebview
On Windows,
pywebviewrequires Visual Studio Build Tools to compile.
Download Plotly.js (offline charting library, one-time)¶
The time-series charts use Plotly.js, embedded offline to avoid a network
dependency. Place plotly.min.js in the same folder as main.py:
curl -o plotly.min.js https://cdn.plot.ly/plotly-2.27.0.min.js
Without this file, the chart area shows "plotly.min.js not loaded"; everything else still works.
Running¶
# Standard mode (opens a native window if pywebview is installed; otherwise opens a browser automatically)
python main.py
# Demo mode: no COM Port needed, view simulated data directly
python main.py --demo
# No-window mode: Flask only, connect manually via browser at http://127.0.0.1:5000/
python main.py --no-window
# The two flags can be combined
python main.py --no-window --demo
| Flag | Description |
|---|---|
--demo |
starts directly in Demo mode, no hardware connection needed |
--no-window |
only starts the Flask server, no window opens, connect manually via browser |
Packaging as a Standalone Executable (advanced, optional)¶
To package the whole program into a single .exe that needs no Python environment installed:
pip install pyinstaller pywebview
pyinstaller --onefile --noconsole ^
--hidden-import flask ^
--hidden-import pywebview ^
--hidden-import pywebview.platforms.winforms ^
--hidden-import serial ^
main.py
The output lands in dist/main.exe, double-click to run it; no separate
Python or package installation needed.
plotly.min.jsis not bundled into the.exe; it needs to be placed manually in the same folder as the.exe.
Common Installation Issues¶
| Problem | Solution |
|---|---|
pywebview fails to install |
switch to Python 3.11 or 3.12; there's currently no available pythonnet wheel for 3.13+ |
| The chart area shows "plotly.min.js not loaded" | follow the steps above to download plotly.min.js into the same folder as main.py |
| COM Port fails to open, device not found | make sure no other program (e.g. STM32CubeIDE's terminal) is holding the port open |