简体   繁体   中英

“ ImportError: cannot import name CaptchaFields ” - Django

I cloned a working project from BitBucket and tried:
python manage.py runserver

I'm getting the following error:

from captcha.fields import CaptchaField
ImportError: cannot import name CaptchaField

I did install captcha using pip install captcha and it installed without any error.
Following is my captcha folder ( installation directory ) contents

在此处输入图片说明

I tried installing simple-cpatcha , recaptcha manually but didn't help.
I couldn't find captcha zip file to install it manually.

I had similar problem.
Using Django 1.8.2 , Python 2.7 and pip 7.0.1
and command pip install captcha solved it.

I had the same issue by installing the following packages:

pip3 install captcha
pip3 install django-simple-captcha

我在使用 Python 3.7、Django 2.1 的 Mac OS 上遇到了一些问题,通过重新安装django-simple-captcha

pip uninstall django-simple-captcha pip install django-simple-captcha

If you are using an integrated development environment like pycharm with a virtual environment, check if the correct package was installed. That did it for me. Go to the interpreter settings and check the installed package list. If the package captcha comes up, it is the WRONG package. Uninstall it and check the available packages list for django-simple-captcha and install that instead.

You need to import from the field like this

from rest_framework_recaptcha.fields import ReCaptchaField

that worked for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM