You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/troubleshooting/usage.md
+77Lines changed: 77 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,3 +37,80 @@ The `DeviceManager` will not be able to connect to a device defined as
37
37
`TCPIP::device-hostname::INSTR`in the `yaml` file. Changing the resource
38
38
definition to `TCPIP::DEVICE-HOSTNAME::INSTR` will allow the `DeviceManager` to
39
39
connect to the device.
40
+
41
+
---
42
+
43
+
## Packaging `tm_devices` with PyInstaller
44
+
45
+
### Problem:
46
+
47
+
When using [PyInstaller](https://pyinstaller.org/en/stable/) to create an executable that includes `tm_devices`, you may encounter errors such as:
48
+
49
+
- `tm_devices library not installed`(even though it is installed)
50
+
- `ModuleNotFoundError: No module named '3c22db458360489351e4._mypyc'`
51
+
- Functionality dependent on `tm_devices` fails in the packaged app, but works in native Python.
52
+
53
+
This is often due to PyInstaller not correctly packaging compiled dependencies (like `tomli`) or missing package metadata required by `tm_devices`.
54
+
55
+
### Solution:
56
+
57
+
1. **Use a Virtual Environment:**
58
+
59
+
- Always create and activate a virtual environment before installing dependencies and running PyInstaller. This ensures all required packages are present and isolated.
60
+
- Example:
61
+
```bash
62
+
python -m venv .venv
63
+
64
+
.venv\Scripts\activate # Windows
65
+
# or
66
+
source .venv/bin/activate # Linux/Mac
67
+
68
+
pip install tm_devices pyinstaller tomli==2.0.1
69
+
```
70
+
71
+
2. **Install `tomli==2.0.1`:**
72
+
73
+
- The error caused by the missing `*_mypyc` files is due to PyInstaller not detecting compiled `tomli` files. Use `tomli` version 2.0.1 as a workaround.
74
+
- Check your version:
75
+
```bash
76
+
pip show tomli
77
+
```
78
+
- If needed, install the correct version:
79
+
```bash
80
+
pip install tomli==2.0.1
81
+
```
82
+
83
+
3. **Include `tm_devices` Metadata:**
84
+
85
+
- Use the `--copy-metadata=tm_devices` flag when running PyInstaller to ensure package metadata is included.
0 commit comments