Having never used Virtual Environments before, and being forced (more or less) into using one because I'm on a RPi 5 and Bookworm, I've tried to set up one so I can run a previously working Python script from a RPi 4 and Bullseye. The code needs the paho-mqtt and bluepy packages, which I have installed into the venv (main). I moved the program into the venv directory, activated the venv, and then tried to run the program. You can see that in the below copy/paste.
But the code fails and says the bluepy package isn't installed. So I ran a pip list to see what packages are installed, and it looks to me like both needed package are in the venv. See below...
So, I am obviously missing something. Can someone point out my, probably obvious, error?
Code:
pi@rpi5dt:~/python/main $ ls -latotal 36drwxr-xr-x 5 pi pi 4096 Jan 23 09:09 .drwxr-xr-x 3 pi pi 4096 Jan 23 08:40 ..drwxr-xr-x 2 pi pi 4096 Jan 23 08:36 bindrwxr-xr-x 3 pi pi 4096 Jan 23 08:18 include-rwxr-xr-x 1 pi pi 9633 Jan 23 08:52 jbd-bms-mqtt.pydrwxr-xr-x 3 pi pi 4096 Jan 23 08:18 liblrwxrwxrwx 1 pi pi 3 Jan 23 08:18 lib64 -> lib-rw-r--r-- 1 pi pi 158 Jan 23 09:08 pyvenv.cfgpi@rpi5dt:~/python/main $ source /home/pi/python/main/bin/activate(main) pi@rpi5dt:~/python/main $ sudo python /home/pi/python/main/jbd-bms-mqtt.py -a "a4:c1:37:31:b8:d0" -i 0 -t solar/laundryTraceback (most recent call last): File "/home/pi/python/main/jbd-bms-mqtt.py", line 32, in <module> from bluepy.btle import Peripheral, DefaultDelegate, BTLEExceptionModuleNotFoundError: No module named 'bluepy'(main) pi@rpi5dt:~/python/main $
Code:
(main) pi@rpi5dt:~/python/main $ python -m pip listPackage Version---------------------------------- ----------arandr 0.1.11...bluepy 1.3.0...paho-mqtt 1.6.1...zipp 1.0.0(main) pi@rpi5dt:~/python/main $
Statistics: Posted by madmacks59 — Tue Feb 06, 2024 5:48 pm