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

Python • lunch venv and python scipt on startup

$
0
0
Hi All,

I am bulding a meteo station on raspbeery pi that uses some specific library (minimal modbus, requests..etc). all those modules are installed in a virtual environment. The scripts works fine when lunched from the venv.
I am struggling to automate the launch of this py script at the pi startup.
I tried creating a sh file that runs : 1-activate the .meteo venv. 2-run the Python file. when running the file I have an error saying that the Modbus library is not installed. obviously the virtual environment was not lunched correctly.

I did do a chmod 777 on the sh script
Here my sh script

Code:

source /home/rafik/pythonEnvs/.meteo/bin/activate python3 /home/rafik/modbus/modbusMultiCloud.py 
When I tried running it as bash it says that he is not able to find the script!!

Code:

#!/bin/bashsource /home/rafik/pythonEnvs/.meteo/bin/activate python3 /home/rafik/modbus/modbusMultiCloud.py 

Statistics: Posted by rafik — Fri Nov 29, 2024 4:46 pm



Viewing all articles
Browse latest Browse all 1241

Trending Articles