October 10, 2026

The mac mini -- my Spectro program

This is a python program that talks to a BW spectrometer using a USB to serial adapter. Getting it to run will be a way to investigate various things. I have it on Github, so I can just clone it to get started: Cloning it via ssh means I can easily push back any changes I make.
ssh chispa
git clone git@github.com:trebisky/Spectro.git
cd Spectro
./gui
The first thing that arises is that I need "wx", so ...
brew install wxpython
This pulls in 14 packages.

pyserial virtual environment hell

Now I need "serial" for python. You would think that "brew install pyserial" would just work, but there are some weird issues for no apparent reason.

Just using "pip3" scolds me that my environment is managed outside of pip (namely by brew). I try "brew install serial" and this installs a serial "cask", but python is still lost.

The recommendation is to use a virtual enviroment.

Lured into using pipx

I got some misinformation, namely that "pipx" can conveniently manage the virtual enviroment thing for me. This is not true, as I learn. I now read that pipx is not at all intended for managing libraries like wx or serial, but is a way to handle entire applications. Maybe.

Not knowing any better, I gave it a try.

brew install pipx
pipx install pyserial
pipx ensurepath
The last command adds /Users/tom/.local/bin to the PATH environment variable, which apparently is important. I need to log out and back in again to get the new PATH. After doing this, it is again looking for wxpython. And using "pipx install wxpython" gives some crazy error about building wheels.

Erradicate the filthy vile pipx

Now I am in a weird situation where brew tells me that wxpython is installed, but when I run my program it tells me that wx is missing.

Here is an "explanation" of pipx. It all sounds nice, sort of, if it only worked. On a moments reflection, any intelligent person will realize that we already have too many package managers, and there is no sense in adding yet another, especially when it does not work

So, away with it!
brew uninstall pipx
This is a good first step perhaps, but it still has roots and has left its dirty footprints all over my nice clean floor. We can also do this:
rm -rf .local
We also edit .bashrc to get rid of the addition to our PATH. We do the same for .bash_profile
brew uninstall wxpython
brew install wxpython
But still "import wx" from inside python3 fails. We abandon all this and learn how to use virtual environments.

I'll go with a rant at this point. This kind of thing is one of the weak points of python, as well as other parts of the open source world. Fragmentation is bad. A multitude of package managers (here we have brew, pip, pipx, as well as the regular software installed by Apple) that cannot get along with each other spells misery for evryone. No doubt someone is busy right now working on yet another package manager for python.

Go the virtual environment route

The moral of the story is to use virtual environments, then use pip.
cd ~/Spectro
python3 -m venv venv
source venv/bin/activate
(venv) tom@chispa:
pip install --upgrade pip
pip install wxpython
pip install pyserial
This is easy and it works.

Find the serial port

Now my software runs, but fails looking for COM3 -- which is exactly what we might expect. So I grab the USB to serial cable, plug it in, and see absolutely nothing.

I plug the device into my linux system, and see:

Oct 10 16:40:19 trona kernel: usb 1-1.3: new full-speed USB device number 77 using ehci-pci
Oct 10 16:40:19 trona kernel: usb 1-1.3: New USB device found, idVendor=067b, idProduct=23a3, bcdDevice= 3.05
Oct 10 16:40:19 trona kernel: usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Oct 10 16:40:19 trona kernel: usb 1-1.3: Product: USB-Serial Controller
Oct 10 16:40:19 trona kernel: usb 1-1.3: Manufacturer: Prolific Technology Inc.
Oct 10 16:40:19 trona kernel: usb 1-1.3: SerialNumber: DCBBb132J03
Oct 10 16:40:19 trona kernel: usbcore: registered new interface driver pl2303
Oct 10 16:40:19 trona kernel: usbserial: USB Serial support registered for pl2303
Oct 10 16:40:19 trona kernel: pl2303 1-1.3:1.0: pl2303 converter detected
Oct 10 16:40:19 trona kernel: usb 1-1.3: pl2303 converter now attached to ttyUSB0
So it is based on a Prolific pl2303 chip. Apparently Apple doesn't include a driver for this like linux does. I have to go find it and figure out how to install it.

I need to go to the Apple App store. I click on the apple at the upper left corner. This gives a menu with "App store" easy to find. I type "prolific serial" into the search entry and among the things it finds I see PL2303 serial. I select "get", then "install". I see the applications icon in the Doc hop up and down. (Lucky me).

I find "Prolific Serial" among the applications and select it. It will apparently install the driver for one time use right now -- or (as it coaches me) I can enable it in "Login items and extensions", which is certainly a good idea. It gives me a button to go to System Settings and there it is with a switch alongside, which I enable.

I plug it in and type:

ls -lrt /dev
crw-rw-rw-  1 root   wheel      0x9000006 Oct 10 16:54 tty.PL2303G-USBtoUART130
crw-rw-rw-  1 root   wheel      0x9000007 Oct 10 16:54 cu.PL2303G-USBtoUART130
A suggestion is to do this -- and we may need to because MacOS may assign a different name each time we plug it in.
ls /dev/{cu,tty}.P*

Conclusion

Maybe we should have a wrapper script called "run" with 2 lines:
source venv/bin/activate
./gui
And now we do.
Have any comments? Questions? Drop me a line!