COINMARKETCAP SENSOR: ImportError: You must install the python package: sqlite3

Hello everyone,

I’m having issues with the Coinmarketcap sensor that persist since 0.55. Before everything went fine. Somehow there seems to be an issue with sqlite and error logs suggest to install python package sqlite. I’ve tried:

sudo apt-get install sqlite3

and

sudo apt-get install libsqlite3

but did not solve the issue. Can anyone help?

THE LOGS:

Nov 04 08:35:43 schneekluth hass[28246]: KeyError: 'sqlite'
Nov 04 08:35:43 schneekluth hass[28246]: During handling of the above exception, another exception occurred:
Nov 04 08:35:43 schneekluth hass[28246]: Traceback (most recent call last):
Nov 04 08:35:43 schneekluth hass[28246]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 170, in _async_setup_platform
Nov 04 08:35:43 schneekluth hass[28246]:     SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
Nov 04 08:35:43 schneekluth hass[28246]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
Nov 04 08:35:43 schneekluth hass[28246]:     return fut.result()
Nov 04 08:35:43 schneekluth hass[28246]:   File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
Nov 04 08:35:43 schneekluth hass[28246]:     raise self._exception
Nov 04 08:35:43 schneekluth hass[28246]:   File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
Nov 04 08:35:43 schneekluth hass[28246]:     result = self.fn(*self.args, **self.kwargs)
Nov 04 08:35:43 schneekluth hass[28246]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/coinmarketcap.py", line 55, in setup_platform
Nov 04 08:35:43 schneekluth hass[28246]:     CoinMarketCapData(currency, display_currency).update()
Nov 04 08:35:43 schneekluth hass[28246]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/coinmarketcap.py", line 133, in update
Nov 04 08:35:43 schneekluth hass[28246]:     convert=self.display_currency)
Nov 04 08:35:43 schneekluth hass[28246]:   File "/srv/homeassistant/lib/python3.5/site-packages/coinmarketcap/core.py", line 54, in ticker
Nov 04 08:35:43 schneekluth hass[28246]:     response = self.__request('ticker/' + currency, params)
Nov 04 08:35:43 schneekluth hass[28246]:   File "/srv/homeassistant/lib/python3.5/site-packages/coinmarketcap/core.py", line 28, in __request
Nov 04 08:35:43 schneekluth hass[28246]:     response_object = self.session.get(self.base_url + endpoint, params = params, timeout = self.request_timeout)
Nov 04 08:35:43 schneekluth hass[28246]:   File "/srv/homeassistant/lib/python3.5/site-packages/coinmarketcap/core.py", line 21, in session
Nov 04 08:35:43 schneekluth hass[28246]:     self._session = requests_cache.core.CachedSession(cache_name='coinmarketcap_cache', backend='sqlite', expire_after=120)
Nov 04 08:35:43 schneekluth hass[28246]:   File "/srv/homeassistant/lib/python3.5/site-packages/requests_cache/core.py", line 68, in __init__
Nov 04 08:35:43 schneekluth hass[28246]:     self.cache = backends.create_backend(backend, cache_name, backend_options)
Nov 04 08:35:43 schneekluth hass[28246]:   File "/srv/homeassistant/lib/python3.5/site-packages/requests_cache/backends/__init__.py", line 54, in create_backend
Nov 04 08:35:43 schneekluth hass[28246]:     _backend_dependencies[backend_name])
Nov 04 08:35:43 schneekluth hass[28246]: ImportError: You must install the python package: sqlite3

Its looking for a python package rather than a system one, so inside your virtual environment, I think you need to do

pip3 install sqlite3

Thanks for you fast reply, @gpbenton. I’ve already tried your solution (sorry, forgot to mention that in my post). When I run your suggested command it gives me:

pip3 install sqlite3
Collecting sqlite3
  Could not find a version that satisfies the requirement sqlite3 (from versions: )
No matching distribution found for sqlite3

What makes me wonder is the fact that it was working fine until 0.55. Even on the latest 0.57 release this issue persists.

Error in 0.57.1:

2017-11-09 22:31:25 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform coinmarketcap
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 170, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/coinmarketcap.py", line 55, in setup_platform
    CoinMarketCapData(currency, display_currency).update()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/coinmarketcap.py", line 129, in update
    from coinmarketcap import Market
  File "/srv/homeassistant/lib/python3.5/site-packages/coinmarketcap/__init__.py", line 10, in <module>
    from .core import Market
  File "/srv/homeassistant/lib/python3.5/site-packages/coinmarketcap/core.py", line 6, in <module>
    import requests_cache
  File "/srv/homeassistant/lib/python3.5/site-packages/requests_cache/__init__.py", line 28, in <module>
    from .core import(
  File "/srv/homeassistant/lib/python3.5/site-packages/requests_cache/core.py", line 21, in <module>
    ver = tuple(map(int, requests.__version__.split(".")))
AttributeError: module 'pip._vendor.requests.__version__' has no attribute 'split'

Still errors in 0.57.3

Hey @Bob_NL,

0.57.3 also changed nothing for me but this seems to be a known issue with the coinmarketcap sensor. I’ve opened an issue on Github that has been closed recently due being a duplicate. They’ve left open this issue so maybe you wanna have a look at it to see if there is progress.

By the way: I’m no longer getting the error about the missing sqlite3 package but another problem occured: sqlite3.OperationalError: unable to open database file

1 Like