iancmcc/ouimeaux

from ouimeaux.environment import Environment error

Closed this issue · 3 comments

Installed pip-3.2 and installed ouimeaux using "sudo pip-3.2 install ouimeaux" and then again trying "sudo pip-3.2 install ouimeaux --target=/usr/local/lib/python3.2/dist-packages/"

Just tried to play with some of the tutorial commands in the shell and can't import the package.

$ python3 --version
Python 3.2.3
pi@raspberrypi ~/Projects $ python3
Python 3.2.3 (default, Mar  1 2013, 11:53:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ouimeaux.environment import Environment
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/dist-packages/ouimeaux/environment.py", line 4, in <module>
    import requests
  File "/usr/local/lib/python3.2/dist-packages/requests/__init__.py", line 52, in <module>
    from .packages.urllib3.contrib import pyopenssl
  File "/usr/local/lib/python3.2/dist-packages/requests/packages/__init__.py", line 39, in <module>
    from . import idna
  File "/usr/local/lib/python3.2/dist-packages/requests/packages/idna/__init__.py", line 1, in <module>
    from .core import *
  File "/usr/local/lib/python3.2/dist-packages/requests/packages/idna/core.py", line 10
    _unicode_dots_re = re.compile(u'[\u002e\u3002\uff0e\uff61]')
                                                              ^
SyntaxError: invalid syntax
>>> 

Any idea what I can do to resolve this? Thanks.

Thanks so much for your help. I used the ouimeaux python package last year on python 2.7 and loved it.

I used a guide (https://procrastinative.ninja/2014/07/20/install-python34-on-raspberry-pi/) to compile and install Python 3.4 in a virtual environment and installed ouimeaux using pip3.

I have a simple python script based on the documentation:

from ouimeaux.environment import Environment
import socket

def on_switch(switch):
print("Switch found!", switch.name)
def on_motion(motion):
print("Motion found!", motion.name)

env = Environment(on_switch, on_motion)

env.start()

But that results in a networking error from gevent. Does ouimeaux / gevent require ipv6?

Traceback (most recent call last):
  File "test.py", line 12, in <module>
    env.start()
  File "/home/pi/.virtualenvs/python34/lib/python3.4/site-packages/ouimeaux/environment.py", line 86, in start
    self.registry.server.start()
  File "/home/pi/.virtualenvs/python34/lib/python3.4/site-packages/gevent/baseserver.py", line 304, in start
    self.init_socket()
  File "/home/pi/.virtualenvs/python34/lib/python3.4/site-packages/gevent/pywsgi.py", line 1451, in init_socket
    StreamServer.init_socket(self)
  File "/home/pi/.virtualenvs/python34/lib/python3.4/site-packages/gevent/server.py", line 127, in init_socket
    self.socket = self.get_listener(self.address, self.backlog, self.family)
  File "/home/pi/.virtualenvs/python34/lib/python3.4/site-packages/gevent/server.py", line 138, in get_listener
    return _tcp_listener(address, backlog=backlog, reuse_addr=cls.reuse_addr, family=family)
  File "/home/pi/.virtualenvs/python34/lib/python3.4/site-packages/gevent/server.py", line 224, in _tcp_listener
    sock = socket(family=family)
  File "/home/pi/.virtualenvs/python34/lib/python3.4/site-packages/gevent/_socket3.py", line 81, in __init__
    self._sock = self._gevent_sock_class(family, type, proto, fileno)
OSError: [Errno 97] Address family not supported by protocol

I can't seem to find what this error from gevent means other than I'm guessing it can't resolve a hostname...? I have been googling and am wondering if this has to do with my /etc/hosts file?

$ cat /etc/hosts
127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

The following error appears when resolving 'localhost,' I do not have a DNS server running.

$ host localhost
localhost has address 127.0.0.1
Host localhost not found: 2(SERVFAIL)
Host localhost not found: 2(SERVFAIL)

This is also running on a Raspberry Pi flavor of Linux:

 $ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 7.11 (wheezy)
Release:        7.11
Codename:       wheezy

I tried playing with ouimeaux on python 3.4.3 on Ubuntu 14.04 LTS VM and everything seems to work fine, so it just appears to be a problem with resolving the address on the RPI. Thanks so much for your help!