8 Replies Latest reply on Dec 8, 2014 9:37 AM by rgb

    How to set Python Environment prior to login so can run a python program at startup

    rgb

      Hi All

      I am trying to run a python program that activates the I2C bus and displays the IP address on a I2C LCD.

      I have a script that runs ntpd and then starts a python program on startup, but when the program  needs to load the SMBus library, it can't find it.

       

      Starting ntpd: Traceback (most recent call last):
        File "/media/realroot/wiring/testLCD.py", line 27, in <module>
          bus = SMBus(0)
      IOError: [Errno 2] No such file or directory

       

      The commands that set up the I2C bus at the start of the program run  and a status file is created letting me know this is successful, but once it tries to use  the first library it dies.

      from smbus import SMBus
      import time
      bus = SMBus(0)
      import lcddriver
      import socket
      #import os
      from subprocess import Popen, PIPE
      lcd = lcddriver.lcd()

      I think the problem is that prior to log in the Python path is not set. I tried to set it in the startup script, but it didn't work.

      Anyone have any ideas?

      regards

      rgb