Brewslee
Posts: 9
Joined: Sun Mar 04, 2018 12:42 pm

traceback error after import gpiozero

Wed Mar 07, 2018 5:46 pm

Hi!

I have got a problem with my python and I hope someone can help me. I have a raspberry pi 3 and try to use a PIR sensor that's why I used this example code:

Code: Select all

from gpiozero import MotionSensor

pir = MotionSensor(4)

while True:
        pir.wait_for_motion()
        print("You moved")
        pir.wait_for_no_motion()
After that, I get this error:

Code: Select all

Traceback (most recent call last):
  File "/home/pi/Desktop/motion detector.py", line 1, in <module>
    from gpiozero import MotionSensor
  File "/usr/lib/python3/dist-packages/gpiozero/__init__.py", line 58, in <module>
    from .devices import (
  File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 18, in <module>
    import pkg_resources
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1467, in exec_module
  File "<frozen importlib._bootstrap>", line 1570, in get_code
  File "<frozen importlib._bootstrap>", line 656, in _compile_bytecode
ValueError: bad marshal data (invalid reference)
>>> 
I already try to reinstall gpiozero but it didn't help.
In another thread from me, someone recommended it to me that I post in the python forum. I hope it is the right forum for this post.
What can I do to prevent this error?
I hope I phrased my question correctly if there are any outstanding question I bid you to ask them.

Return to “Python”