# Pb pour un lancer un service avec systemctl

**URL:** <https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456>\
**Category:** Support Debian\
**Created:** [Janvier 22, 2024, 8:45 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456 "2024-01-22T08:45:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![duboeric](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@duboeric](https://www.debian-fr.org/u/duboeric)\
**Post date:** [Janvier 22, 2024, 8:45 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456/1 "2024-01-22T08:45:39Z")

</div>

Salut,  
Voilà j’ai un pb avec systemctl et un service qui ne fonctionne pas. J’utilise raspbian bullseye.  
Je suis plutôt débutant sur linux.  
Voilà la structure de mon fichier .service

```auto
[Unit]
Description=RFLinkGateway
After=multi-user.target
Conflicts=getty@tty1.service

[Service]
Type=simple
WorkingDirectory=/opt/scripts/RFLinkGateway
# Set correct path
ExecStart=/bin/python3 /opt/scripts/RFLinkGateway/RFLinkGateway.py
user=root
User=root

[Install]
WantedBy=multi-user.target

```

lorsque je lance mon programme RFLinkGateway.py de mon dossier où se trouve mes fichiers de config. Cela fonctionne : trace ci-dessous

```nohighlight
pi@raspberrypi:/opt/scripts/RFLinkGateway $ /bin/python3 /opt/scripts/RFLinkGateway/RFLinkGateway.py
2024-01-22 08:28:16,203 - RFLinkGW.SerialProcessing - __init__ - INFO - Starting...
2024-01-22 08:28:16,209 - RFLinkGW.SerialProcessing - connect - INFO - Connecting to serial
2024-01-22 08:28:17,218 - RFLinkGW.SerialProcessing - connect - DEBUG - Serial connected
2024-01-22 08:28:17,243 - RFLinkGW.MQTTClient - __init__ - INFO - Starting...
2024-01-22 08:28:18,170 - RFLinkGW.SerialProcessing - prepare_output - DEBUG - Received message:['20', '00', 'Nodo RadioFrequencyLink - RFLink Gateway V1.1 - R48']

```

Si je le lance avec systemctl, voilà le résultat :

```nohighlight
pi@raspberrypi:/opt/scripts/RFLinkGateway $ sudo systemctl status RFLinkGateway.service
● RFLinkGateway.service - RFLinkGateway
     Loaded: loaded (/lib/systemd/system/RFLinkGateway.service; enabled; vendor pres>
     Active: failed (Result: exit-code) since Mon 2024-01-22 08:39:58 GMT; 10s ago
    Process: 12181 ExecStart=/bin/python3 /opt/scripts/RFLinkGateway/RFLinkGateway.p>
   Main PID: 12181 (code=exited, status=1/FAILURE)
        CPU: 1.370s

Jan 22 08:39:57 raspberrypi systemd[1]: Started RFLinkGateway.
Jan 22 08:39:58 raspberrypi python3[12181]: Traceback (most recent call last):
Jan 22 08:39:58 raspberrypi python3[12181]: File "/opt/scripts/RFLinkGateway/RFLin>
Jan 22 08:39:58 raspberrypi python3[12181]: import tornado.gen
Jan 22 08:39:58 raspberrypi python3[12181]: ModuleNotFoundError: No module named 'to>
Jan 22 08:39:58 raspberrypi systemd[1]: RFLinkGateway.service: Main process exited, >
Jan 22 08:39:58 raspberrypi systemd[1]: RFLinkGateway.service: Failed with result 'e>
Jan 22 08:39:58 raspberrypi systemd[1]: RFLinkGateway.service: Consumed 1.370s CPU t>

```

Hors lorsque je lance python3, j’ai bien tornado de présent :

```nohighlight
pi@raspberrypi:/ $ python3
Python 3.9.2 (default, Mar 12 2021, 04:06:34) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tornado
>>> 

```

Quelle serait mon erreur ?  
Merci  
Eric

---

<div class="post-metadata">

**Author:** ![Zargos](https://www.debian-fr.org/user_avatar/www.debian-fr.org/zargos/32/10889_2.png) [@Zargos](https://www.debian-fr.org/u/Zargos)\
**Post date:** [Janvier 22, 2024, 8:57 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456/2 "2024-01-22T08:57:19Z")

</div>

> [@duboeric](#):
>
> Jan 22 08:39:58 raspberrypi python3[12181]: ModuleNotFoundError: No module named 'to\>

Bonjour,

Tu as un problème de chargement de module semble-t-il.  
As-tu réussi à faire cette connexion manuellement?

---

<div class="post-metadata">

**Author:** ![duboeric](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@duboeric](https://www.debian-fr.org/u/duboeric)\
**Post date:** [Janvier 22, 2024, 9:05 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456/3 "2024-01-22T09:05:38Z")

</div>

Merci pour la réactivité 😉  
Si par module c’est l’importation du module tornado de python3. Ma réponse est oui et j’arrive bien à importer import tornado.gen avec python3.  
Pour preuve, c’est lorsque je lance mon prog python à la mano, ça fonctionne

---

<div class="post-metadata">

**Author:** ![MPython\_Alaplancha](https://www.debian-fr.org/user_avatar/www.debian-fr.org/mpython_alaplancha/32/14038_2.png) [@MPython\_Alaplancha](https://www.debian-fr.org/u/MPython_Alaplancha)\
**Post date:** [Janvier 22, 2024, 9:29 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456/4 "2024-01-22T09:29:09Z")

</div>

Bonjour,  
Peut être un souci avec le chemin absolu de ton interpréteur python.  
Ce ne serait pas plutôt /usr/bin/python3 ?  
Tu peux le vérifier avec `which python3`

---

<div class="post-metadata">

**Author:** ![duboeric](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@duboeric](https://www.debian-fr.org/u/duboeric)\
**Post date:** [Janvier 22, 2024, 1:25 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456/5 "2024-01-22T13:25:08Z")

</div>

C’était bien vu, effectivement l’interpréteur python3, c’est /usr/bin/python3 lorsque que je lance la commande which python3.  
Par contre malgré la modification et un daemon-reload toujours la même erreur :

```nohighlight
● RFLinkGateway.service - RFLinkGateway
     Loaded: loaded (/lib/systemd/system/RFLinkGateway.service; enabled; vendor preset: e>
     Active: failed (Result: exit-code) since Mon 2024-01-22 12:00:05 GMT; 6s ago
    Process: 14319 ExecStart=/usr/bin/python3 /opt/scripts/RFLinkGateway/RFLinkGateway.py>
   Main PID: 14319 (code=exited, status=1/FAILURE)
        CPU: 1.452s

Jan 22 12:00:04 raspberrypi systemd[1]: Started RFLinkGateway.
Jan 22 12:00:05 raspberrypi python3[14319]: Traceback (most recent call last):
Jan 22 12:00:05 raspberrypi python3[14319]: File "/opt/scripts/RFLinkGateway/RFLinkGate>
Jan 22 12:00:05 raspberrypi python3[14319]: import tornado.gen
Jan 22 12:00:05 raspberrypi python3[14319]: ModuleNotFoundError: No module named 'tornado'

```

??

---

<div class="post-metadata">

**Author:** ![duboeric](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/d/ba9def/32.png) [@duboeric](https://www.debian-fr.org/u/duboeric)\
**Post date:** [Janvier 22, 2024, 6:13 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456/6 "2024-01-22T18:13:44Z")

</div>

Pour info, j’ai solutionné mon pb avec  
sudo chmod -R o+rx /usr/local/lib/python3.9  
Donc ce serait un pb de droit, étrange, mais aprés ce changement de droit ds le répertoire pip3, ça fonctionne.

---

<div class="post-metadata">

**Author:** ![MPython\_Alaplancha](https://www.debian-fr.org/user_avatar/www.debian-fr.org/mpython_alaplancha/32/14038_2.png) [@MPython\_Alaplancha](https://www.debian-fr.org/u/MPython_Alaplancha)\
**Post date:** [Janvier 23, 2024, 9:47 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456/7 "2024-01-23T09:47:59Z")

</div>

La bonne façon de faire aurait été de créer un environnement virtuel où tu installes tes dépendances et utiliser l’interpréteur python de cet environnement…

---

<div class="post-metadata">

**Author:** ![Zargos](https://www.debian-fr.org/user_avatar/www.debian-fr.org/zargos/32/10889_2.png) [@Zargos](https://www.debian-fr.org/u/Zargos)\
**Post date:** [Janvier 23, 2024, 9:54 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456/8 "2024-01-23T09:54:58Z")

</div>

Un question, pourquoi ne pas utiliser le python de la distribution et ajouter un python manuellement?

---

<div class="post-metadata">

**Author:** ![MPython\_Alaplancha](https://www.debian-fr.org/user_avatar/www.debian-fr.org/mpython_alaplancha/32/14038_2.png) [@MPython\_Alaplancha](https://www.debian-fr.org/u/MPython_Alaplancha)\
**Post date:** [Janvier 23, 2024, 6:22 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456/9 "2024-01-23T18:22:48Z")

</div>

Je ne comprends pas ta question. Tu demandes pourquoi utiliser un environnement virtuel?

---

<div class="post-metadata">

**Author:** ![Zargos](https://www.debian-fr.org/user_avatar/www.debian-fr.org/zargos/32/10889_2.png) [@Zargos](https://www.debian-fr.org/u/Zargos)\
**Post date:** [Janvier 23, 2024, 6:24 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456/10 "2024-01-23T18:24:10Z")

</div>

Non :

> [@duboeric](#):
>
> /usr/local/lib/python3.9

Ce n’est pas une installation par les paquets debian il me semble?

---

<div class="post-metadata">

**Author:** ![MPython\_Alaplancha](https://www.debian-fr.org/user_avatar/www.debian-fr.org/mpython_alaplancha/32/14038_2.png) [@MPython\_Alaplancha](https://www.debian-fr.org/u/MPython_Alaplancha)\
**Post date:** [Janvier 23, 2024, 6:29 UTC](https://www.debian-fr.org/t/pb-pour-un-lancer-un-service-avec-systemctl/89456/11 "2024-01-23T18:29:11Z")

</div>

Ok je croyais que tu réagissais à ma réponse précédente… d’ou mon incompréhention
