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

Python • Re: venv for newbs - setting up a service to run on startup but is contained in a venvq

$
0
0
Hi all!
Sorry I'm totally green to all of this and looking at setting up a python script to run on start up.
All signs from what I've been reading point to using a venv rather than `sudo apt python-<somepackage>` and then calling source /somepath/activate

I was wondering how that then impacts running a service on startup from that venv and what general practices are there?
Sorry I am venturing over from windows land so I'm even greener than most :)
Yes, managing Python modules/libraries can be confusing.

First, using virtual environments helps with keeping things organized. When not using VENV you have to be careful when and when not to use SUDO. SUDO will place the software at the system level; without SUDO, it places it in your user account space. This is important because how you run your Python script determines where Python looks for IMPORTS; system or user.

Also, personally, I use PIP rather than APT for installing Python Modules/Libraries.

Full disclosure, I've had very little exposure to VENV's. My one occurrence cause problems because I needed to run under SUDO which VENV does not seem to like.

In terms of running a Python VENV script, there is documentation out there. See https://www.google.com/search?q=runnin+ ... &ie=UTF-8 . Here is one example https://gist.github.com/nmpowell/d44482 ... 2ee4f591cf

In terms of running something at start up, see this excellent guide viewtopic.php?t=314455

Good luck

Statistics: Posted by DS256 — Mon Sep 16, 2024 12:33 pm



Viewing all articles
Browse latest Browse all 1246

Trending Articles