I tried to run my docker image for my django project and I have got a error:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.10/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.10/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.10/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.10/site-packages/gunicorn/util.py", line 359, in import_app
mod = importlib.import_module(module)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/code/Eventful-main/eventful/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/usr/local/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/usr/local/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.10/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/usr/local/lib/python3.10/site-packages/django/apps/config.py", line 301, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/local/lib/python3.10/site-packages/social_django/models.py", line 8, in <module>
from .storage import DjangoUserMixin, DjangoAssociationMixin, \
File "/usr/local/lib/python3.10/site-packages/social_django/storage.py", line 8, in <module>
from social_core.storage import UserMixin, AssociationMixin, NonceMixin, \
File "/usr/local/lib/python3.10/site-packages/social_core/storage.py", line 9, in <module>
from openid.association import Association as OpenIdAssociation
File "/usr/local/lib/python3.10/site-packages/openid/__init__.py", line 52, in <module>
if len(version_info) != 3:
TypeError: object of type 'map' has no len()
I tried to use different version of python but always same issue back to me!
Here my docker file
FROM python:3
RUN pip install --upgrade pip
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY . /code/
RUN pip install -r requairements.txt
EXPOSE 8000
CMD ["gunicorn", "--chdir", "Eventful-main", "--bind", ":8000", "eventful.wsgi:application"]
CodePudding user response:
Check the answer from Object of type 'map' has no len() in Python 3
"In Python 3, map returns a map object not a list. You can convert it into a list then get the length from there:
>>> print(len(list(L)))
10
"
In your case:
if len(list(version_info)) != 3:
CodePudding user response:
print(len(map.keys()))
You can use the length of the key in the map to calculate the length of the map