0

I used pyinstaller 3.5 to create an executable from a python script. to compile i used:

pyinstaller -F --onefile --add-data :. my_script.py

I'm trying to run this executable as systemd service. The service file is:

   ***[Unit]

   Description= a description

   [Service]

   Type=simple

   Restart=on-failure

   User=root

   RestartSec=3

   ExecStart=/usr/bin/python3 path/to/my_script

   [Install]

   WantedBy=multi-user.target***

When i start the service via systemctl start service i get the following error:

   :SyntaxError: Non-UTF-8 code starting with '\xe8' in file /path/to/my_script on line 2, but no 
    encoding declared; see http://python.org/dev/peps/pep-0263/ for details

and the service is exiting with status=1/FAILURE

When i'm running the service my_script.py everything works great.

I don't use in my code non utf-8 characters.

I tried to add encoding defenition of all sorts. for example:

***\# -*- coding: latin-1 -*-***

I tried commenting almost every line in the code to find the source but i kept getting the error. I saw a similar problem here Error when using pyinstaller: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff but the fix they suggested didn't work for me

Anyone knows how to solve it?

I'm working with python 3.6.9

Linux red hat 7.5

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
stopiky
  • 1
  • 1

0 Answers0