Doesn't load config file when launched from a startup script

Issue #17 resolved
Travis Travelstead created an issue

I am working on getting a python GUI to load during startup and python-can fails to load with this error.

raise ImportError("CAN interface not found")

After it fails and I am in userspace (as root) I run the same script and it runs without issue. My only guess is that it cannot load the required "can.config" file because it is not running as the root user yet.

Is is possible to fix this in the script or avoid the "can.config" file and just hardcode the interface information?

Comments (8)

  1. Brian Thorne repo owner

    If you are planning to use as both a non privileged user and as root I would put the config in your global configuration directory /etc/can.conf.

    It is also possible to use environment variables as well, see can/

  2. Travis Travelstead reporter

    Brian, you have been amazing with the support of your product.

    This solves my immediate problem. I do thing the option to use the config would be nice over being required.

    Thanks again!

  3. Brian Thorne repo owner

    No worries. Please submit further issues as they come up. Contributions are welcome if you think the documentation could be clearer too!

  4. grend Julien


    I am working on can interface with python-can and I've the same problem that Travis :

    raise ImportError("CAN interface not found")

    I put my can.conf file in /ect

    I work with python2.7 and i'm root. When I test my interface with candump or CanSend function. can0 interface works

    Why python-can fonction doesn't detect my can interface ?


  5. Travis Travelstead reporter


    Let me see if I can help.

    the "/ect/" folder is used during boot, but I also have the config file in "/root/" for when I am testing the files after the system is already booted. So if you are waiting for the system to boot and then you are executing the files yourself, I would suggest to put then in "/root/" or whatever user you currently are logged in as.

    Hope that helps

  6. georges619


    I've installed Python-Can on my beaglebone, and I think there is a file missing called can.config" in the /etc/ folder. My question is : is this normal ? Or do I need to create this file manually ?

    P.S: I'm starting with python-can.


  7. georges619

    Hello Travis ! Thanks for your reply ! Everything works perfectly now ! I had to create the can.config folder, and I had to install the can-utils tools.

    Thanks ;)

  8. Log in to comment