[SOLVED]Error home assistant pycountry

Hi,I have a odroid C1 with dietpi v6.34.3, and I install HA through dietpi-software.
I have an error with HA when I try to add a custom components.
This is the error

2020-12-22 13:02:41 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
    return await handler(request)
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/components/http/ban.py", line 73, in ban_middleware
    return await handler(request)
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/components/http/view.py", line 125, in handle
    result = await result
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/components/config/config_entries.py", line 112, in post
    return await super().post(request)
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/components/http/data_validator.py", line 54, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/helpers/data_entry_flow.py", line 68, in post
    result = await self._flow_mgr.async_init(
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/data_entry_flow.py", line 117, in async_init
    flow = await self.async_create_flow(handler, context=context, data=data)
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/config_entries.py", line 505, in async_create_flow
    integration.get_platform("config_flow")
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/homeassistant/loader.py", line 272, in get_platform
    cache[full_name] = importlib.import_module(
  File "/home/homeassistant/.pyenv/versions/3.8.0/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 "/mnt/dietpi_userdata/homeassistant/custom_components/smartthinq_sensors/config_flow.py", line 3, in <module>
    import pycountry
  File "/mnt/dietpi_userdata/homeassistant/deps/lib/python3.8/site-packages/pycountry/__init__.py", line 12, in <module>
    __version__ = pkg_resources.get_distribution("pycountry").version
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pkg_resources/__init__.py", line 481, in get_distribution
    dist = get_provider(dist)
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pkg_resources/__init__.py", line 357, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/home/homeassistant/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pycountry' distribution was not found and is required by the application

I don’t know I have this error, I have already installed this component and it work, after an update the component dosen’t work and I try to delete and reinstall, but I have this error.
I run this command

su -s /bin/bash homeassistant
pip3 install pycountry
Requirement already satisfied: pycountry in /usr/lib/python3/dist-packages (17.5.14)

I don’t know how resolve
Thanks

Solved
On the system there are python 3.7 and when I run pip3 install pycountry don’t update HA, because HA use another version of python inside homeassistant folder.
So i run this command
/home/homeassistant/.pyenv/versions/3.8.0/bin/pip3 install pycountry

Yes indeed, you would need to use HA own pyenv. :wink:

You could use following

sudo -u homeassistant dash -c '. /home/homeassistant/pyenv-activate.sh; pip3 install pycountry