0

File "/opt/folder/api/views.py", line 63, in from django_earthdistance.models import EarthDistance, LlToEarth File "/opt/folder/venv/lib/python3.8/site-packages/django_earthdistance/models.py", line 4, in from django.utils import six ImportError: cannot import name 'six' from 'django.utils' (/

I am finally moving to Python3 from Python2 and I just have about everything wrapped up, but I am getting this error from the dango-earthdistance package which hasn't been updated for a couple of years and apparently doesn't support the latest version of Python3 that I'm using (3.8.9). This lets me calculate distances with lat and lng in Postgres.

What's my best option?

  • Seems you already know that the package you are using does not support Python 3, I'm not entirely sure what answer you expect, except for "look for another package" or "implement the logic you need on your own" – DeepSpace Oct 28 '21 at 23:23
  • @DeepSpace, there is actually an [already-existing compatibility package](https://pypi.org/project/django-utils-six/) to solve this exact issue. "Look for another package" and "implement the logic" are not the only two possibilities. – James Mishra Oct 28 '21 at 23:26
  • @JamesMishra It seems to try to fix compatibility issues between different versions of Django, not Python, but hey, if it works for OP then good for them :) – DeepSpace Oct 28 '21 at 23:28
  • @DeepSpace, yes, the OP's problem is because [django-earthdistance](https://pypi.org/project/django-earthdistance/) depends on a library vendored in Django 2.0 and removed in Django 3.0. Other than that issue, the django-earthdistance library claims to support Python 3.3. – James Mishra Oct 28 '21 at 23:31

1 Answers1

0

Six is a package of tools for writing code that is compatible with both Python 2 and Python 3.

Django used to vendor their own copy of Six until they removed it in Django 3.0.

django-earthdistance is still looking for Django's copy of the Six library, and you can bring it back by installing the django-utils-six package.

See this related question for more information.

James Mishra
  • 4,249
  • 4
  • 30
  • 35