#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2017
    Posts
    7
    Rep Power
    0

    ImportError: No module named helpers


    Hi all,

    I run a sample Python code, it has following error

    Code:
    ==============
    Traceback (most recent call last):
      File "./rtc.py", line 6, in <module>
        from helpers import DBUS_INTERFACE_PREFIX, DBUS_PATH_PREFIX, readFromFile, writeToFile, cleanObjectName
    ImportError: No module named helpers
    ==============
    I am a newbie for Python, what is the error and how to solve it?

    This error comes from the following line in my code
    "from helpers import DBUS_INTERFACE_PREFIX, DBUS_PATH_PREFIX, readFromFile, writeToFile, cleanObjectName"

    Any help is appreciated.

    Thanks.
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,824
    Rep Power
    509
    Find out if the helpers module exists on your computer. It might be a directory by that name containing an __init__.py file, or it might be helpers.py or it could be a dynamic link library or shared object.

    Once you've found that or installed it to a location you know about it will need to be on the python path. Set the environment variable PYTHONPATH before running python, for example in bash:
    $ PYTHONPATH=$PYTHONPATH:location_of_helpers_module
    $ python3 super_program.py


    or you can set the variable within python, as I recall

    import sys
    sys.path.append('location_of_helpers_module')

    import super_program
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2017
    Posts
    7
    Rep Power
    0
    Thank you so much for your support! You are a very good and kind person!

IMN logo majestic logo threadwatch logo seochat tools logo