早上好,我正在尝试在 Otree 中使用 Google 验证码,我安装了 recaptcha 并创建了一个给我密钥的帐户,但是当我运行 powershell 时,它向我显示以下错误:
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\otree_startup\__init__.py", line 202, in do_django_setup
django.setup()
File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "c:\users\user\appdata\local\programs\python\python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "c:\users\user\appdata\local\programs\python\python37\lib\site-packages\captcha\__init__.py", line 18, in <module>
"Setting %s is not of type" % variable, instance_type
django.core.exceptions.ImproperlyConfigured: ('Setting RECAPTCHA_PUBLIC_KEY is not of type', <class 'str'>)
这是我设置中的代码,enviroment.get 代码用于在 Heroku 上运行实验。
RECAPTCHA_PUBLIC_KEY = ' RECAPTCHA_PUBLIC_KEY '
RECAPTCHA_PRIVATE_KEY = ' RECAPTCHA_PUBLIC_KEY '
RECAPTCHA_PUBLIC_KEY = environ.get('RECAPTCHA_PUBLIC_KEY')
RECAPTCHA_PRIVATE_KEY = environ.get('RECAPTCHA_PRIVATE_KEY')
关键是数字,我不知道如何使验证码有效,有人可以给出一个想法吗?