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

AttributeError: 'module' object has no attribute 'REQUIREMENTS' #1

Closed
genestealer opened this issue Feb 26, 2017 · 4 comments
Closed
Assignees
Labels

Comments

@genestealer
Copy link

Error when trying to run for the 1st time:

sudo python -m pi_mqtt_gpio.server /home/pi/code/config.yml
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/pi_mqtt_gpio/server.py", line 96, in <module>
    install_missing_requirements(gpio_module)
  File "/usr/local/lib/python2.7/dist-packages/pi_mqtt_gpio/server.py", line 29, in install_missing_requirements
    reqs = getattr(module, "REQUIREMENTS")
AttributeError: 'module' object has no attribute 'REQUIREMENTS'

RPi.GPIO is already installed:

pip install RPi.GPIO
Requirement already satisfied: RPi.GPIO in /usr/lib/python2.7/dist-packages

Config file:

mqtt:
  host: localhost
  port: 1883
  user: ""
  password: ""
  topic_prefix: pimqttgpio/mydevice

gpio_modules:
  - name: raspberrypi
    module: raspberrypi
  - name: dev
    module: stdio

digital_inputs:
  - name: button
    module: raspberrypi
    pin: 21
    on_payload: "ON"
    off_payload: "OFF"
    pullup: no
    pulldown: yes

digital_outputs:
  - name: test
    module: dev
    pin: 1
    on_payload: "ON"
    off_payload: "OFF"

Any ideas?

@genestealer
Copy link
Author

Same error when trying the other example:

Config file:

mqtt:
  host: test.mosquitto.org
  port: 1883
  user: ""
  password: ""
  topic_prefix: home

gpio_modules:
  - name: raspberrypi
    module: raspberrypi

digital_inputs:
  - name: doorbell
    module: raspberrypi
    pin: 22
    on_payload: "ON"
    off_payload: "OFF"
    pullup: yes
    pulldown: no

Output:

pi@raspberrypi:~ $ python -m pi_mqtt_gpio.server /home/pi/code/config.yml
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/pi_mqtt_gpio/server.py", line 111, in <module>
    for output_config in config["digital_outputs"]:
KeyError: 'digital_outputs'

@flyte
Copy link
Owner

flyte commented Feb 26, 2017

Looks like you found a bug (or two)!

  • I didn't make REQUIREMENTS optional for the modules, and then didn't put it in the stdio module.
  • The code makes an assumption that both the digital_inputs and digital_outputs config sections exist.

These should now be fixed, but I don't have a Pi handy for testing it out.

Thank you very much for the details. Please let me know of any further issues :)

@flyte
Copy link
Owner

flyte commented Feb 26, 2017

Closing the bug for now, as I've tested it superficially without the raspberrypi module. I may endeavour to tidy this project up a bit if someone else is actually using it :)

@flyte flyte closed this as completed Feb 26, 2017
@flyte
Copy link
Owner

flyte commented Feb 26, 2017

I also forgot to mention that I've just pushed a new version (0.0.3) including this fix. You should now be able to do a pip install --upgrade pi-mqtt-gpio

@flyte flyte self-assigned this May 17, 2017
@flyte flyte added the bug label Jul 26, 2017
flyte pushed a commit that referenced this issue Nov 23, 2017
* inital test

* Syntax

* Retain works as it should

* Just local things

* Fix for #1

python or yaml made that easy

* Forgot tp change the schema on github

* Update .gitignore

* Update README.md

* Spaces not tabes

* Spaces not tabs

* Decided it didnt need logging

* Spaces not tabs

* Requested changes for #2
flyte pushed a commit that referenced this issue Jan 24, 2020
Adding sensor interface and LM75 i2c sensor support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants