Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesnt see rpi-gpio library although already installed #1

Open
PGtheVRguy opened this issue Jun 20, 2024 · 0 comments
Open

Doesnt see rpi-gpio library although already installed #1

PGtheVRguy opened this issue Jun 20, 2024 · 0 comments

Comments

@PGtheVRguy
Copy link

As title explains, I have integrated the example code into a project, installed the library correctly, but everytime the project is run it errors out at the import line with the library recommending I run pip install rpi-gpio, although I already have it installed. Then, when ran I get told the requirement is already met.

(luma-env) pi@watch:~ $ python3 applications/test/main.py 
Traceback (most recent call last):
  File "/home/pi/luma-env/lib/python3.11/site-packages/rotary_encoder/_rotary_encoder.py", line 17, in <module>
    import rotary_encoder_gpio_core as gpio  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/luma-env/lib/python3.11/site-packages/rotary_encoder_gpio_core/__init__.py", line 23, in <module>
    from rotary_encoder_gpio_core._gpio import *
ModuleNotFoundError: No module named 'rotary_encoder_gpio_core._gpio'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/applications/test/main.py", line 2, in <module>
    import rotary_encoder
  File "/home/pi/luma-env/lib/python3.11/site-packages/rotary_encoder/__init__.py", line 1, in <module>
    from rotary_encoder._rotary_encoder import connect, CallbackHandling
  File "/home/pi/luma-env/lib/python3.11/site-packages/rotary_encoder/_rotary_encoder.py", line 19, in <module>
    raise MissingGPIOLibraryError(
rotary_encoder._rotary_encoder.MissingGPIOLibraryError: Could not import RPi.GPIO. If this code is running on a raspberry pi, make sure that the rpi-gpio library is installed. You may install it by running `pip install rpi-gpio`.
(luma-env) pi@watch:~ $ 

Here is the actual code of the project

from PIL import Image, ImageDraw, ImageFont
import rotary_encoder
import RPi.GPIO as GPIO
import sys
import os
import subprocess
import time

sys.path.insert(1, '/home/pi/')
import render
from functions import buttonHandler, mathClass, drawClass
import constants as c


image = Image.new("1", (128,64))
draw = ImageDraw.Draw(image)
fnt5x8 = ImageFont.truetype('fonts/5x8.ttf')

draw.rectangle((0,0, 128, 64), fill = "black")
drawClass.draw_text((128/2, 32), "Test app!", fnt5x8, draw, "center")
time.sleep(1)

counter = 0

def increment():
    global counter
    counter += 1
    print(counter)


def decrement():
    global counter
    counter -= 1
    print(counter)


def press():
    print("PRESS")


def release():
    print("RELEASE")




with rotary_encoder.connect(
    clk_pin=20,                           # required
    dt_pin=21,                            # required
    on_clockwise_turn=increment,          # optional
    on_counter_clockwise_turn=decrement,  # optional
):
    draw.rectangle((0,0, 128, 64), fill = "black")

    drawClass.draw_text((128/2, 32), counter, fnt5x8, draw, "center")

    render.render_image(image)

the draw_text, render_image, and other function are apart of an OLED display system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant