element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum lirc help
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 10 replies
  • Answers 6 answers
  • Subscribers 664 subscribers
  • Views 2151 views
  • Users 0 members are here
  • rasberry_pi_3_b_plus
  • raspberry_pi
  • lirc
  • import
Related

lirc help

rgiguere
rgiguere over 6 years ago

OK i know this is probably a total newb  question but i am a new. I have RPI 3 B+ and im creating a mp3 player as a project for my intro to electronics engineering course. Ive downloded lirc created my remotes profile and all is working on that end but when i try to import it into my program (written with python 3)  i get "ImportError: No module named 'lirc'". SO what am i doing wrong? everything went as smooth as it could setting the remote up and i cant find anything on the web about why it wont import so im hoping someone here can help or give me advice at least. thancks in advanceimage

  • Sign in to reply
  • Cancel
  • mconners
    0 mconners over 6 years ago

    Did you do

     

    pip install python-lirc

     

    to install the python package?

     

    Mike

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • mconners
    0 mconners over 6 years ago in reply to mconners

    https://pypi.org/project/python-lirc

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • rgiguere
    0 rgiguere over 6 years ago in reply to mconners

    I used sudo apt-get install lirc

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mconners
    0 mconners over 6 years ago in reply to rgiguere

    Well, you need to install the python module, that's why you can't find it when you import.

     

    Follow the link I attached above and do what it says and it should solve your import problem.

     

    Mike

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • rgiguere
    0 rgiguere over 6 years ago in reply to mconners

    OK now im able to import lirc  but when i run the command

    import lirc

     

     

    sockid = lirc.init("juke01", blocking=False)

    #lirc.set_blocking(False, sockid)

    print(lirc.nextcode())

    lirc.deinit()

     

    it just prints []

    it doesnt actually print the key name

    heres acopy of my .lircrc

     

    begin

      prog=Juke_MMF_v001.3

      remote=juke01

      button=KEY_PLAYPAUSE

      config=xplay

    END

    begin

      prog = Juke_MMF_v001.3

      remote = juke01

      button = KEY_PREVIOUS

      config = previous

    END

    begin

      prog = Juke_MMF_v001.3

      remote = juke01

      button = KEY_NEXT

      config = next

    END

    begin

      prog = Juke_MMF_v001.3

      remote = juke01

      button = KEY_EQUAL

      config = stop

    END

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • mconners
    0 mconners over 6 years ago in reply to rgiguere

    I've never actually used lirc, but looking at the example on the page I linked, It looks like

    the init line needs to match the prog line

     

    so replace

     

    sockid = lirc.init("juke01", blocking=False)

     

    with

     

    sockid = lirc.init("Juke_MMF_v001.3", blocking=False)

     

    and I don't really know if the button names you have in the config are valid.

     

    There is a simple example on the linked page as well. I would suggest copying that verbatim and make sure that works.

     

    Mike

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • rgiguere
    0 rgiguere over 6 years ago in reply to mconners

    Ok ill try that im still getting the hang of this as i just started with it i really appreciate your help

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mconners
    0 mconners over 6 years ago in reply to rgiguere

    No problem. Once you get it working let us know what you had to do. It may help someone in the future.

     

    Mike

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • rgiguere
    0 rgiguere over 6 years ago in reply to mconners

    Thanks for everything Michael im glad ive finnaly found a forum where people dont just throw answers at you! So aparently there are a few different versions of lirc for python depending on what version of python you are coding in depends on what version of lirc you need the original lirc only support linix and to make it work you must install pylirc for python to act as a so called middle man to communicate between the 2. For python2 use pip install python2-lirc and for python3 pip install python3-lirc as these 2 contain binders for python built into them last but not least when initializing  lirc sockid =lirc. init("prog", blocking=false) where prog is the name of your program you are running NOT THE PROGRAM FILE OF THE RWMOTE.  As i made this mistake but everything is working as it should.

    Im sure yall will be hereing fron me again as i am a new student to electronics  and programming thank you again for all your help

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mconners
    0 mconners over 6 years ago in reply to rgiguere

    I'm glad you were able to get stuff squared away. Most folks around here try to be helpful and if we don't know the answer, we try to point you in the direction we would take if we were trying to solve the problem for ourselves. That way you come away not only with a solution to your problem, but the tools and skills you need to solve other problems you might encounter in the future.

     

    Thanks for coming back and reporting your findings, it may help someone else now.

     

     

    Mike

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube