Python version problem? requests_async import error

Hello, I don’t know, maybe it’s a python problem?

    File "/srv/homeassistant/lib/python3.7/site-packages/envoy_reader/envoy_reader.py", line 8, in <module>
    import requests_async as requests
ModuleNotFoundError: No module named 'requests_async'

I’m trying to use an updated version of a component (envoy_reader) which uses requests-async (this fails: import requests_async as requests) I did have 0.93.1, and I upgraded to 0.94.1 homeassistant. still same issue.

I ran pip3 install requests-async and I think it installed? but I can’t find a requests-async file, and I still get the import error.
$ pip3 install re
quests-async
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: requests-async in /home/homeassistant/.local/lib/python3.7/site-packa
ges (0.6.0)
Requirement already satisfied: requests==2.* in /usr/lib/python3/dist-packages (from requests-async)
(2.21.0)
Requirement already satisfied: http3==0.1.* in /home/homeassistant/.local/lib/python3.7/site-package
s (from requests-async) (0.1.1)
Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from http3==0.1.->request
s-async) (2018.8.24)
Requirement already satisfied: idna==2.
in /usr/lib/python3/dist-packages (from http3==0.1.->reque
sts-async) (2.6)
Requirement already satisfied: chardet==3.
in /usr/lib/python3/dist-packages (from http3==0.1.->re
quests-async) (3.0.4)
Requirement already satisfied: rfc3986==1.
in /home/homeassistant/.local/lib/python3.7/site-package
s (from http3==0.1.->requests-async) (1.3.2)
Requirement already satisfied: h11==0.8.
in /home/homeassistant/.local/lib/python3.7/site-packages
(from http3==0.1.->requests-async) (0.8.1)
Requirement already satisfied: h2==3.
in /home/homeassistant/.local/lib/python3.7/site-packages (fr
om http3==0.1.->requests-async) (3.1.0)
Requirement already satisfied: hyperframe<6,>=5.2.0 in /home/homeassistant/.local/lib/python3.7/site
-packages (from h2==3.
->http3==0.1.->requests-async) (5.2.0)
Requirement already satisfied: hpack<4,>=2.3 in /home/homeassistant/.local/lib/python3.7/site-packag
es (from h2==3.
->http3==0.1.*->requests-async) (3.0.0)

Checking python version, and showing what version of homeassistant (haspbian) I have:
homeassistant@hassbian:~ $ python --version
Python 2.7.16 <<<<<<<< Is THIS ok ???

homeassistant@hassbian:~ $ sudo hassbian-config upgrade python
Generating system information...

  Home Assistant:        0.94.4
  Home Assistant Python: 3.7.3
  hassbian-config:       0.13.1

  Linux hassbian 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux
  

Suite:     Python
Installed: false
Contributed to the project by Ludeeus <https://github.com/ludeeus>
Upgrades python3 and virtual environment to the newest stable version.

Checking current python version...
Python is already the highest stable version.

Operation completed...

Were you in the hassbian venv when you installed requests-async?

1 Like

Thanks @nickrout !

What do you mean by being ‘in’ the venv? the venv is /srv/homeassistant directory? There’s more to it than that I think.

I did some searching, this post and this post helped with understanding the venv.

I did the following, and it gets past the import error now, and I see requests_async in the ha site packages directory.

homeassistant@hassbian:~ $ source /srv/homeassistant/bin/activate
(homeassistant) homeassistant@hassbian:~ $ which python
/srv/homeassistant/bin/python
(homeassistant) homeassistant@hassbian:~ $ ha hah!!! 
ha hahwhich python! 
bash: ha: command not found
(homeassistant) homeassistant@hassbian:~ $ pip3 install requests-async
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting requests-async
  Downloading https://files.pythonhosted.org/packages/d9/3a/0172435fa886d658e31741ea509fbb0c0d6209b1df13657c2450667dc2ef/requests-async-0.6.1.tar.gz
Requirement already satisfied: requests==2.* in /srv/homeassistant/lib/python3.7/site-packages (from requests-async) (2.22.0)
Collecting http3==0.1.* (from requests-async)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /srv/homeassistant/lib/python3.7/site-packages (from requests==2.*->requests-async) (1.24.3)
Requirement already satisfied: idna<2.9,>=2.5 in /srv/homeassistant/lib/python3.7/site-packages (from requests==2.*->requests-async) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /srv/homeassistant/lib/python3.7/site-packages (from requests==2.*->requests-async) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /srv/homeassistant/lib/python3.7/site-packages (from requests==2.*->requests-async) (2019.6.16)
Collecting h2==3.* (from http3==0.1.*->requests-async)
  Using cached https://files.pythonhosted.org/packages/a6/b2/0348a08cce9980b15ef8607adc7f0534193fe25b9269daa0c327dc74f026/h2-3.1.0-py2.py3-none-any.whl
Collecting h11==0.8.* (from http3==0.1.*->requests-async)
  Using cached https://files.pythonhosted.org/packages/f9/f3/8e4cf5fa1a3d8bda942a0b1cf92f87815494216fd439f82eb99073141ba0/h11-0.8.1-py2.py3-none-any.whl
Collecting rfc3986==1.* (from http3==0.1.*->requests-async)
  Using cached https://files.pythonhosted.org/packages/00/8d/9d56bfe43997f1864fe0891be69bc239ded98e69c9f56eb9eaa5b1789660/rfc3986-1.3.2-py2.py3-none-any.whl
Collecting hyperframe<6,>=5.2.0 (from h2==3.*->http3==0.1.*->requests-async)
  Using cached https://files.pythonhosted.org/packages/19/0c/bf88182bcb5dce3094e2f3e4fe20db28a9928cb7bd5b08024030e4b140db/hyperframe-5.2.0-py2.py3-none-any.whl
Collecting hpack<4,>=2.3 (from h2==3.*->http3==0.1.*->requests-async)
  Using cached https://files.pythonhosted.org/packages/8a/cc/e53517f4a1e13f74776ca93271caef378dadec14d71c61c949d759d3db69/hpack-3.0.0-py2.py3-none-any.whl
Building wheels for collected packages: requests-async
  Building wheel for requests-async (setup.py) ... done
  Stored in directory: /home/homeassistant/.cache/pip/wheels/62/a9/8e/a1f067183c73cadd1d9cdcf6cc7845fe5b150738035b609e0d
Successfully built requests-async
Installing collected packages: hyperframe, hpack, h2, h11, rfc3986, http3, requests-async
Successfully installed h11-0.8.1 h2-3.1.0 hpack-3.0.0 http3-0.1.1 hyperframe-5.2.0 requests-async-0.6.1 rfc3986-1.3.2
(homeassistant) homeassistant@hassbian:~ $

yes that is what I meant. Does that work now?

1 Like

Yes, it did install and work, once the package was installed into ha’s venv.

can this be done in hassio?

No it can’t.