Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4990

Python • Activating a venv at boot time

$
0
0
I'm going round in circles on this...

I have a Python script written in a virtual environment (I was forced to use a venv to get the necessary libraries to install - I'd have referred not to!)

Anyway, the script is finished & works on my PiZero2W, when the venv is actrivated & the script itself is called from the commandline.

However, nothing I do seems to get it to run automatically on boot.

I've created a crontab which successfully calls another script, (to activate the venv and run the pythion code)cd lo, as follows (this must be the 20th iteration):

Code:

#!/bin/bash# launcher.sh# navigate to home directory, then to this directory, then execute python scriptcd /../home/RpiDSC/shared/RpiDSC-venvsource /bin/activatepython ./RpiDSC2.py
The result (in the) cronlog is this:

Code:

/home/RpiDSC/launcher.sh: 8: source: not foundTraceback (most recent call last):  File "/home/RpiDSC/shared/RpiDSC-venv/./RpiDSC2.py", line 4, in <module>    from ST7789 import ST7789ModuleNotFoundError: No module named 'ST7789'
The venv isn't getting activated, meaning my python script, runs, but fails, as it can't find the libraries it needs.

So.. what am I doing wrong here??

cheers

Paul

Statistics: Posted by ubercoder — Fri Feb 14, 2025 8:41 pm — Replies 2 — Views 17



Viewing all articles
Browse latest Browse all 4990

Trending Articles