Harke,

You should try running your script from the cli using the exact same
command you use for the exec start line in your service file. It should
give you the same errors you are seeing. That would be good. If not, the
problem is that your environment doesn't match. It will probably end up
being your PYTHONPATH. In that case you may want to write a short bash
script which sets the path and runs your python script, and using that for
your exec start command.

Fundamentally your python doesn't know where the libraries you want are
installed. PYTHONPATH is the environment variable which tends python where
to look. Copy the one from your environment and export it in your bash
script.

Jim

On Wed, Dec 5, 2018, 2:50 PM Harke Smits <[email protected]> wrote:

> login as: debian
> debian@Beaglebone's password:
>
> The programs included with the Debian GNU/Linux system are free software;
> the exact distribution terms for each program are described in the
> individual files in /usr/share/doc/*/copyright.
>
> Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
> permitted by applicable law.
> Last login: Wed Dec  5 18:01:26 2018 from
> 2001:982:c7c1:1:a96e:5bfc:cb2a:81a7
> debian@beaglebone:~$ sudo systemctl status aceme
> [sudo] password for debian:
> ● aceme.service - to invoke aceme.py automatically
>    Loaded: loaded (/etc/systemd/system/aceme.service; enabled; vendor
> preset: enabled)
>    Active: failed (Result: exit-code) since Wed 2018-12-05 19:39:44 UTC;
> 3min 50s ago
>   Process: 986 ExecStart=/home/debian/eme/acemev35.py (code=exited,
> status=1/FAILURE)
>  Main PID: 986 (code=exited, status=1/FAILURE)
>
> Dec 05 19:39:40 beaglebone systemd[1]: Started to invoke aceme.py
> automatically.
> Dec 05 19:39:44 beaglebone python[986]: Adafruit_BBIO: version <unknown>
> initialized
> Dec 05 19:39:44 beaglebone acemev35.py[986]: Traceback (most recent call
> last):
> Dec 05 19:39:44 beaglebone acemev35.py[986]:   File
> "/home/debian/eme/acemev35.py", line 21, in <module>
> Dec 05 19:39:44 beaglebone acemev35.py[986]:     import serial
>    # serial control module
> Dec 05 19:39:44 beaglebone acemev35.py[986]: ImportError: No module named
> serial
> Dec 05 19:39:44 beaglebone systemd[1]: aceme.service: Main process exited,
> code=exited, status=1/FAILURE
> Dec 05 19:39:44 beaglebone systemd[1]: aceme.service: Unit entered failed
> state.
> Dec 05 19:39:44 beaglebone systemd[1]: aceme.service: Failed with result
> 'exit-code'.
> debian@beaglebone:~$
>
>
> here is the status of aceme.service immediately after booting. It is clear
> that serial is loaded on my system, as I use it extensively in the same
> program script loaded.
> login as: debian
> debian@Beaglebone's password:
>
> The programs included with the Debian GNU/Linux system are free software;
> the exact distribution terms for each program are described in the
> individual files in /usr/share/doc/*/copyright.
>
> Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
> permitted by applicable law.
> Last login: Wed Dec  5 18:01:26 2018 from
> 2001:982:c7c1:1:a96e:5bfc:cb2a:81a7
> debian@beaglebone:~$ sudo systemctl status aceme
> [sudo] password for debian:
> ● aceme.service - to invoke aceme.py automatically
>    Loaded: loaded (/etc/systemd/system/aceme.service; enabled; vendor
> preset: enabled)
>    Active: failed (Result: exit-code) since Wed 2018-12-05 19:39:44 UTC;
> 3min 50s ago
>   Process: 986 ExecStart=/home/debian/eme/acemev35.py (code=exited,
> status=1/FAILURE)
>  Main PID: 986 (code=exited, status=1/FAILURE)
>
> Dec 05 19:39:40 beaglebone systemd[1]: Started to invoke aceme.py
> automatically.
> Dec 05 19:39:44 beaglebone python[986]: Adafruit_BBIO: version <unknown>
> initialized
> Dec 05 19:39:44 beaglebone acemev35.py[986]: Traceback (most recent call
> last):
> Dec 05 19:39:44 beaglebone acemev35.py[986]:   File
> "/home/debian/eme/acemev35.py", line 21, in <module>
> Dec 05 19:39:44 beaglebone acemev35.py[986]:     import serial
>    # serial control module
> Dec 05 19:39:44 beaglebone acemev35.py[986]: ImportError: No module named
> serial
> Dec 05 19:39:44 beaglebone systemd[1]: aceme.service: Main process exited,
> code=exited, status=1/FAILURE
> Dec 05 19:39:44 beaglebone systemd[1]: aceme.service: Unit entered failed
> state.
> Dec 05 19:39:44 beaglebone systemd[1]: aceme.service: Failed with result
> 'exit-code'.
> debian@beaglebone:~$ sudo nano /etc/systemd/system/aceme.service
>   GNU nano 2.7.4                                File:
> /etc/systemd/system/aceme.service
>
> [Unit]
> Description=to invoke aceme.py automatically
> Requires=graphical.target
>
> [Service]
> Type=simple
> ExecStart=/home/debian/eme/acemev35.py
>
> [Install]
> WantedBy=multi-user.target
>
>                                                         [ Read 11 lines ]
> The service file above......
>
>
> Grtz,
> Harke
>
> On Wed, 5 Dec 2018 at 05:16, Jim F <[email protected]> wrote:
>
>> I actually think what you need to do is something along the following
>> line. I don't think the shebang line makes a difference (rather, I know
>> this) if you pass the python script directly to the python binary.
>>
>> ExecStart=/usr/bin/python2.7 /path/to/my_file.py
>>
>> You should post your errors if Seth's or my comments don't get you on
>> track.
>>
>> Jim
>>
>> On Wed, Dec 5, 2018 at 12:23 AM Mala Dies <[email protected]> wrote:
>>
>>> Okay and Hello Once More,
>>>
>>> Seth here. I think (know) Jim F was on to something w/ your software and
>>> setting up .service files for running on boot.
>>>
>>> For example: Here is another test example to try out to learn more about
>>> .service files and starting files on boot on the BBB (or other related
>>> bbb.io boards).
>>>
>>> ...
>>>
>>> #!/usr/bin/python
>>>
>>> import Adafruit_BBIO.GPIO as GPIO
>>> import time
>>>
>>> #your awesome software
>>>
>>> ...
>>>
>>> Now...that example, like w/ what Jim F was typing out, is an example not
>>> for your use. You will need to replace all the software w/ your software
>>> but do use the first line.
>>>
>>> Oh...here is an example of that file above in Python in a .service file
>>> w/ the name Pluck.py as the file name. Oh and let us call the .service file
>>> Pluck.service.
>>>
>>> [Unit]
>>> Description=Some Amount of Understanding for Your File
>>>
>>> [Service]
>>> ExecStart=/home/debian/Pluck.py
>>>
>>> [Install]
>>> WantedBy=multi-user.target
>>>
>>> Now...try to run your .service file that should be saved in
>>> /etc/systemd/system/ as Pluck.service.
>>>
>>> ...
>>>
>>> Then, type this command: sudo systemctl enable Pluck.service
>>>
>>> Then, type this command: sudo systemctl start Pluck.service
>>>
>>> That should do it!
>>>
>>> If not, please reply w/ any relative ideas that are preventing your use
>>> of a file on boot, e.g. errors and why the started .service file is not
>>> working on boot.
>>>
>>> Seth
>>>
>>>
>>>
>>> On Tuesday, December 4, 2018 at 3:24:25 AM UTC-6, Harke Smits wrote:
>>>>
>>>> Looks like we are close. But the error codes are persistent. I can not
>>>> copy/paste but serial does not load. Whatever I place in the first line of
>>>> the python file.
>>>> I tried: #!/bin/env/python and other shebangs (I learn!) but the error
>>>> remains exactly the same. Btw: I use python2.x
>>>> Any clue what to try next please?
>>>> Cheers,
>>>> Harke
>>>>
>>>>
>>>> On Mon, 3 Dec 2018 at 23:18, Mala Dies <[email protected]> wrote:
>>>>
>>>>> Harke,
>>>>>
>>>>> Did you, in the software example you created, add #!/usr/bin/python3
>>>>> to the top of your program and then use this command: sudo chmod a+x
>>>>> YourFile.py? Now, you should be able to run your .service file like before
>>>>> from the example I had given.
>>>>>
>>>>> Seth
>>>>>
>>>>> On Monday, December 3, 2018 at 6:28:19 AM UTC-6, Harke Smits wrote:
>>>>>>
>>>>>> Thank you for your support Seth! I do not think I am running anything
>>>>>> special. Just one Python script, 400 lines of my code, many thousends in
>>>>>> libs, I guess. From QTerminal command line it runs perfectly. From 
>>>>>> within a
>>>>>> service not.
>>>>>> Looking at your proposal: do you really intend to write: ExecStart=
>>>>>> /path/myprog.py instead of: ExecStart=python /path/myprog.py????
>>>>>> That wonders me.
>>>>>>  I "sudo nano" the service file and then write it in the
>>>>>> /etc/systemd/system/ folder. Nothing else I do.
>>>>>> Is that sufficient?
>>>>>> Thanks a lot again.
>>>>>> Regards,
>>>>>> Harke
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, 3 Dec 2018 at 05:17, Mala Dies <[email protected]> wrote:
>>>>>>
>>>>>>> Hello Harke,
>>>>>>>
>>>>>>> Seth here. Um, are you trying to run a specific piece of software
>>>>>>> only or are you trying to run multiple pieces of software?
>>>>>>>
>>>>>>> Seth
>>>>>>>
>>>>>>> P.S. I know you have to make a file accessible at
>>>>>>> /etc/systemd/system/<your .service file here> w/ the proper 
>>>>>>> instructions in
>>>>>>> that .service file. Now, to make it run should be easy, i.e. if this is
>>>>>>> just one piece of software.
>>>>>>>
>>>>>>> [Unit]
>>>>>>> Description=More of what will happen!
>>>>>>>
>>>>>>> [Service]
>>>>>>> ExecStart= /your/path/to/the/.py/file.py
>>>>>>>
>>>>>>> [Install]
>>>>>>> WantedBy=multi-user.target
>>>>>>>
>>>>>>> ^
>>>>>>> |
>>>>>>> |
>>>>>>>
>>>>>>> Try this!
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Saturday, December 1, 2018 at 5:48:51 AM UTC-6, Harke Smits wrote:
>>>>>>>>
>>>>>>>> Hi Seth,
>>>>>>>>
>>>>>>>> In the meantime I think I tried just about any combination I can
>>>>>>>> think of.
>>>>>>>> Mostly I get the following error codes after demanding the status;
>>>>>>>> Loaded....
>>>>>>>> Active: failed
>>>>>>>> Process: 1002 ... code = exited, status=203/EXEC
>>>>>>>> Main PID: 1002.....
>>>>>>>>
>>>>>>>> In short; no luck so far........
>>>>>>>> I am doing something fundamentally wrong I think... Or it is just
>>>>>>>> impossible.
>>>>>>>> I am lost here......
>>>>>>>> Cheers,
>>>>>>>> Harke
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, 30 Nov 2018 at 22:46, Mala Dies <[email protected]> wrote:
>>>>>>>>
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>> When you type under [Service], use only the PATH. Try that idea
>>>>>>>>> first. I may be able to help out a bit.
>>>>>>>>>
>>>>>>>>> Seth
>>>>>>>>>
>>>>>>>>> P.S. For instance, say I have a Python file in this dir:
>>>>>>>>> /home/debian/LoveBone/. I would simply put, under the [Service] tag,
>>>>>>>>> ExecStart=/home/debain/LoveBone/MultipleIdeas.py for my PATH. Try 
>>>>>>>>> that idea
>>>>>>>>> and think about moving that [Unit] option for 
>>>>>>>>> Requires=graphical.target.
>>>>>>>>> Try that section under your [Install] section.
>>>>>>>>>
>>>>>>>>> On Friday, November 30, 2018 at 10:50:15 AM UTC-6, Harke Smits
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Hello Seth,
>>>>>>>>>>
>>>>>>>>>> Thanks a lot for your reaction. I already digested these pages
>>>>>>>>>> (as good as I could, I am an RF engineer, not a programmer). 
>>>>>>>>>> Unfortunately
>>>>>>>>>> this does not help me much. The service file is at the correct 
>>>>>>>>>> location.
>>>>>>>>>> I hope to get some clue where I am doing something wrong.
>>>>>>>>>> Thanks again, regards,
>>>>>>>>>> Harke
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Friday, 30 November 2018 12:18:26 UTC+1, Mala Dies wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hello Again Harke,
>>>>>>>>>>>
>>>>>>>>>>> Seth here. You need to put your .service files in
>>>>>>>>>>> /etc/systemd/system/. I am pretty sure.
>>>>>>>>>>>
>>>>>>>>>>> Seth
>>>>>>>>>>>
>>>>>>>>>>> On Monday, November 26, 2018 at 5:49:16 AM UTC-6, Harke Smits
>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hello learned group,
>>>>>>>>>>>>
>>>>>>>>>>>> I have a Python application that I'd like to see start up on
>>>>>>>>>>>> boot. It uses Tkinter, so it needs the graphical environment.
>>>>>>>>>>>> Running: python /home/debian/eme/myprog.py from the QTerminal
>>>>>>>>>>>> command line works as expected. Not outside the LXQT environment, 
>>>>>>>>>>>> which is
>>>>>>>>>>>> normal I think.
>>>>>>>>>>>> I made a service file: myprog.service like this:
>>>>>>>>>>>> [Unit]
>>>>>>>>>>>> Description=to invoke myprog automatically on boot
>>>>>>>>>>>> Requires=graphical.target
>>>>>>>>>>>> [Service]
>>>>>>>>>>>> Type=simple
>>>>>>>>>>>> WorkingDirectory=/home/debian/eme/
>>>>>>>>>>>> ExecStart=python /home/debian/eme/myprog.py
>>>>>>>>>>>> [Install]
>>>>>>>>>>>> WantedBy=multi-user.target
>>>>>>>>>>>>
>>>>>>>>>>>> Service file is located at both: /etc/systemd/system/ and
>>>>>>>>>>>> /lib/systemd/system/ as I am unsure where it actually belongs. Of 
>>>>>>>>>>>> course I
>>>>>>>>>>>> already spend a lot of time at internet to find a solution. Only 
>>>>>>>>>>>> succes
>>>>>>>>>>>> stories here....
>>>>>>>>>>>> I entered the following;
>>>>>>>>>>>> sudo systemctl enable myprog.service: nothing special
>>>>>>>>>>>> sudo systemctl start myprog.service: service is not loaded
>>>>>>>>>>>> properly.....
>>>>>>>>>>>> sudo systemctl status myprog.service: error (invalid argument),
>>>>>>>>>>>> inactive (dead).
>>>>>>>>>>>>
>>>>>>>>>>>> Both from bash or within QTerminal: behaviour is the same.
>>>>>>>>>>>>
>>>>>>>>>>>> Please help me out what to do.
>>>>>>>>>>>> Kind regards,
>>>>>>>>>>>> Harke
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>> For more options, visit http://beagleboard.org/discuss
>>>>>>>>> ---
>>>>>>>>> You received this message because you are subscribed to a topic in
>>>>>>>>> the Google Groups "BeagleBoard" group.
>>>>>>>>> To unsubscribe from this topic, visit
>>>>>>>>> https://groups.google.com/d/topic/beagleboard/goOORlttd2c/unsubscribe
>>>>>>>>> .
>>>>>>>>> To unsubscribe from this group and all its topics, send an email
>>>>>>>>> to [email protected].
>>>>>>>>> To view this discussion on the web visit
>>>>>>>>> https://groups.google.com/d/msgid/beagleboard/91cdcefd-06b6-4d68-96fe-a95b7dcd4573%40googlegroups.com
>>>>>>>>> <https://groups.google.com/d/msgid/beagleboard/91cdcefd-06b6-4d68-96fe-a95b7dcd4573%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>>> .
>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>
>>>>>>>> --
>>>>>>> For more options, visit http://beagleboard.org/discuss
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to a topic in
>>>>>>> the Google Groups "BeagleBoard" group.
>>>>>>> To unsubscribe from this topic, visit
>>>>>>> https://groups.google.com/d/topic/beagleboard/goOORlttd2c/unsubscribe
>>>>>>> .
>>>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>>>> [email protected].
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/beagleboard/7ab54d0b-e341-48ff-89d6-d9fac79ec09a%40googlegroups.com
>>>>>>> <https://groups.google.com/d/msgid/beagleboard/7ab54d0b-e341-48ff-89d6-d9fac79ec09a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>> --
>>>>> For more options, visit http://beagleboard.org/discuss
>>>>> ---
>>>>> You received this message because you are subscribed to a topic in the
>>>>> Google Groups "BeagleBoard" group.
>>>>> To unsubscribe from this topic, visit
>>>>> https://groups.google.com/d/topic/beagleboard/goOORlttd2c/unsubscribe.
>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>> [email protected].
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/beagleboard/2506b7d1-fa75-4e23-8c25-a8eb64b5c603%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/beagleboard/2506b7d1-fa75-4e23-8c25-a8eb64b5c603%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>> --
>>> For more options, visit http://beagleboard.org/discuss
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "BeagleBoard" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/beagleboard/46853aca-953b-41a4-9198-c9f54d791abf%40googlegroups.com
>>> <https://groups.google.com/d/msgid/beagleboard/46853aca-953b-41a4-9198-c9f54d791abf%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> For more options, visit http://beagleboard.org/discuss
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "BeagleBoard" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/beagleboard/goOORlttd2c/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/beagleboard/CAGS%2B2h_cfbGiTxGZTiG74wxrZdi9sBu6Rsurhg9Oav4XmUV-2w%40mail.gmail.com
>> <https://groups.google.com/d/msgid/beagleboard/CAGS%2B2h_cfbGiTxGZTiG74wxrZdi9sBu6Rsurhg9Oav4XmUV-2w%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beagleboard/CAHmciaZXB1PNvQ428rY852r4S%2BbQVfKeWruMsA8VmaoujUusnw%40mail.gmail.com
> <https://groups.google.com/d/msgid/beagleboard/CAHmciaZXB1PNvQ428rY852r4S%2BbQVfKeWruMsA8VmaoujUusnw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/CAGS%2B2h9PxED_NXH9Ma%2BF5Dy-scXqsQQJSUJDnvGWTS%2BPXR-DNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to