polyedre / tuya-lan

A custom component to Home Assistant to integrate Tuya without the use of tuya servers
MIT License
11 stars 1 forks source link

Requirements for tuya_lan not found: ['pytuya'] #2

Open tjonaitis opened 4 years ago

tjonaitis commented 4 years ago

Hi,

I am getting an error after I added sensor in my configuration.yaml file.

Screen Shot 2020-03-16 at 23 23 33

Any ideas why? What I am missing? P.S. all four files are in tuya_lan folder under custom components.

polyedre commented 4 years ago

Could you provide the relevant part of your configuration.yml file ?

tjonaitis commented 4 years ago

Sorry for delayed answer! Please see the attached screenshot.

Screen Shot 2020-04-30 at 20 29 25
polyedre commented 4 years ago

Ok, your configuration seems correct. In the image, Home Assistant seems to fail initializing tuya_lan. You added in the title Requirements for tuya_lan not found: ['pytuya']. I didn't noticed at first. It seems that the pytuya package has not been found. So if you're using a virtual environnement, you may want to install it with pip :

pip install pytuya

Also, make sure that you are running hass inside the environnement.

tjonaitis commented 4 years ago

I am using an old macbook as my home assistant server. What do you mean by saying “make sure that you are running hass inside the environment”? I am getting an error if I try to execute pip install pytuya command:

`ERROR: Command errored out with exit status 1: command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/16/vhmkzwwd79bfv8309sn7_4g00000gn/T/pip-install-mynjvsvu/pytuya/setup.py'"'"'; file='"'"'/private/var/folders/16/vhmkzwwd79bfv8309sn7_4g00000gn/T/pip-install-mynjvsvu/pytuya/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/16/vhmkzwwd79bfv8309sn7_4g00000gn/T/pip-install-mynjvsvu/pytuya/pip-egg-info cwd: /private/var/folders/16/vhmkzwwd79bfv8309sn7_4g00000gn/T/pip-install-mynjvsvu/pytuya/ Complete output (7 lines): Traceback (most recent call last): File "", line 1, in File "/private/var/folders/16/vhmkzwwd79bfv8309sn7_4g00000gn/T/pip-install-mynjvsvu/pytuya/setup.py", line 9, in import pytuya File "/private/var/folders/16/vhmkzwwd79bfv8309sn7_4g00000gn/T/pip-install-mynjvsvu/pytuya/pytuya/init.py", line 45, in log.info('Using PyCrypto %r', Crypto.version_info) AttributeError: module 'Crypto' has no attribute 'version_info'

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. `

polyedre commented 4 years ago

The problem here seems to come from your Crypto module, there are two python modules named "Crypto". The right one can be installed using pip install pycrypto.

What do you mean by saying “make sure that you are running hass inside the environment”?

I just mean that if you are using a python environnement, you need to have run source <env-name>/bin/activate inside your terminal session before running hass :)

tjonaitis commented 4 years ago

So after removing crypto and installing pycrypto as well as wheel package I was able to install pytuya but.. when I check my yaml config before restaring server I am getting this error now:

2020-05-04 22:37:15 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for tuya_lan which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. 2020-05-04 22:37:15 INFO (MainThread) [pytuya] pytuya version 7.0.5 2020-05-04 22:37:15 INFO (MainThread) [pytuya] Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18) [Clang 6.0 (clang-600.0.57)] on darwin 2020-05-04 22:37:15 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 418, in start resp = await task File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/aiohttp/web_app.py", line 458, in _handle resp = await handler(request) File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl return await handler(request) File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware return await handler(request) File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/ban.py", line 73, in ban_middleware return await handler(request) File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/auth.py", line 127, in auth_middleware return await handler(request) File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/homeassistant/components/http/view.py", line 125, in handle result = await result File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/homeassistant/components/config/core.py", line 29, in post errors = await async_check_ha_config_file(request.app["hass"]) File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/homeassistant/config.py", line 830, in async_check_ha_config_file res = await check_config.async_check_ha_config_file(hass) File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/check_config.py", line 164, in async_check_ha_config_file platform = p_integration.get_platform(domain) File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/homeassistant/loader.py", line 278, in get_platform cache[full_name] = importlib.import_module( File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/Users/tomasjonaitis/.homeassistant/custom_components/tuya-lan/sensor.py", line 5, in <module> from pytuya import OutletDevice File "/Users/tomasjonaitis/homeassistant/lib/python3.8/site-packages/pytuya/__init__.py", line 45, in <module> log.info('Using PyCrypto %r', Crypto.version_info) AttributeError: module 'Crypto' has no attribute 'version_info'

polyedre commented 4 years ago

Strange, it seems this is the same problem as your previous comment, did you tried to reload the python environment (with source <env>/bin/activate) ? Maybe the old crypto module has been loaded ? I'm sorry I was unable to reproduce this error

tjonaitis commented 4 years ago

Reloading python environment didn’t help... google.com didn’t help either.