ModuleNotFoundError:没有名为“captcha.fields”的模块

问题描述 投票:0回答:1

在 vscode 终端中执行命令

python manage.py runserver
发生此错误:

Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\commands\runserver.py", line 133, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\base.py", line 486, in check
    all_issues = checks.run_checks(
                 ^^^^^^^^^^^^^^^^^^
  ......
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "D:\<project path>\porsline\urls.py", line 10, in <module>   
    path('', include('survey.urls')),
             ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\urls\conf.py", line 39, in include
    urlconf_module = import_module(urlconf_module)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module     
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "D:\<project path>\survey\urls.py", line 2, in <module>      
    from . import views
  File "D:\<project path>\survey\views.py", line 14, in <module>    
    from . forms import CreateSurveyForm, CreateQuestionForm, ShowSurveyForm
  File "D:\<project path>\survey\forms.py", line 11, in <module>    
    from captcha.fields import CaptchaField
ModuleNotFoundError: No module named 'captcha.fields'

根据顶部消息的最后一行

ModuleNotFoundError: No module named 'captcha.fields'
,我执行了命令
pip3 install django-simple-captcha
pip3 install django-recaptcha
,但问题没有解决。

这个问题有解决办法吗?请帮助我。

注意:我看到没有名为“captcha.fields”的模块但我的问题没有解决!

python django visual-studio-code
1个回答
0
投票

您是否将验证码添加到settings.py中的INSTALLED_APPS中?

然后迁移?

https://django-simple-captcha.readthedocs.io/en/latest/usage.html

© www.soinside.com 2019 - 2024. All rights reserved.