🤍 전 강의 25% 할인 중 🤍

2024년 상반기를 돌아보고 하반기에도 함께 성장해요!
인프런이 준비한 25% 할인 받으러 가기 >>

  • 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    해결됨

AttributeError: module 'collections' has no attribute 'Callable' 에러 처리 방법

22.06.16 02:04 작성 조회수 3.49k

3

강사님 안녕하세요.

강의 영상을 따라하던 중, 이러한 에러가 발생했습니다..

 

project/urls.py

from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.auth.decorators import login_required
from django.urls import path, include
from django.views.generic import TemplateView
from django_pydenticon.views import image as pydenticon_image

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', login_required(TemplateView.as_view(template_name='root.html')), name='root'),
    path('identicon/image/<path:data>/', pydenticon_image,name='pydenticon_image'),
    path('accounts/', include('accounts.urls')),
]

if settings.DEBUG:
    import debug_toolbar
    urlpatterns += [
        path('__debug__/', include(debug_toolbar.urls))
    ]
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

 

project/sttings/common.py

INSTALLED_APPS = [
    # Django Apps
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Third Apps
    'bootstrap4',
    'debug_toolbar',
    'django_pydenticon',
    # Local Apps
    'accounts',
]

 

답변 1

답변을 작성해보세요.

4

honge7694님의 프로필

honge7694

질문자

2022.06.16

아 강사님이 다른 질문에 답변해주신거 보고 해결했습니다!! 감사합니다.

안녕하세요.

현재 파이썬 3.10을 쓰고 계시는 데요. django-pydenticon 내에서 사용되는 collections.Callable 참조가 파이썬 3.10부터 collections.abc.Callable로 이동하여, 제거된 Attribute라서 발생하는 오류입니다.

파이썬 3.9에서 collections.Callable을 참조하면 아래의 경고가 뜹니다.

<stdin>:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working

django-pydenticon이 파이썬 3.10을 지원해야 해결이 되는 이슈인데요.

파이썬 버전을 3.9로 내려서 실행을 해보실수도 있구요.

혹은 몽키패칭이지만, 프로젝트의 settings.py 상단에 다음을 추가하시어, 임시적으로 collections.Callable 속성을 collections.abc.Callable 로부터 복사하시는 방법도 있긴 합니다.

import collections
if not hasattr(collections, 'Callable'):
    collections.Callable = collections.abc.Callable

화이팅입니다. :-)

질 해결하셨습니다. 화이팅입니다. :-)

채널톡 아이콘