小编Had*_*oub的帖子

fake_useragent 模块未正确连接 - IndexError:列表索引超出范围

我尝试将fake_useragent模块与此块一起使用

from fake_useragent import UserAgent

ua = UserAgent()
print(ua.random)
Run Code Online (Sandbox Code Playgroud)

但是当执行到这一行时ua = UserAgent(),它会抛出这个错误

Traceback (most recent call last):
  File "/home/hadi/Desktop/excel/gatewayform.py", line 191, in <module>
    gate = GateWay()
  File "/home/hadi/Desktop/excel/gatewayform.py", line 23, in __init__
    ua = UserAgent()
  File "/usr/local/lib/python3.9/dist-packages/fake_useragent/fake.py", line 69, in __init__
    self.load()
  File "/usr/local/lib/python3.9/dist-packages/fake_useragent/fake.py", line 75, in load
    self.data = load_cached(
  File "/usr/local/lib/python3.9/dist-packages/fake_useragent/utils.py", line 250, in load_cached
    update(path, use_cache_server=use_cache_server, verify_ssl=verify_ssl)
  File "/usr/local/lib/python3.9/dist-packages/fake_useragent/utils.py", line 245, in update
    write(path, load(use_cache_server=use_cache_server, verify_ssl=verify_ssl))
  File "/usr/local/lib/python3.9/dist-packages/fake_useragent/utils.py", line 178, in load
    raise …
Run Code Online (Sandbox Code Playgroud)

python user-agent

6
推荐指数
1
解决办法
5571
查看次数

如何解决 django.core.exceptions.ImproperlyConfigured:请求设置 INSTALLED_APPS 错误?

当我尝试运行python3 poppulate_first_app.py文件(使用 Kali Linux 和 venv 以及 django 3.1.7)时,出现此错误。

错误...

Traceback (most recent call last):
  File "/home/hadi/Documents/first_django_project/poppulate_first_app.py", line 4, in <module>
    from first_app.models import *
  File "/home/hadi/Documents/first_django_project/first_app/models.py", line 6, in <module>
    class Topic(models.Model):
  File "/home/hadi/Documents/first_django_project/venv/lib/python3.9/site-packages/django/db/models/base.py", line 108, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/home/hadi/Documents/first_django_project/venv/lib/python3.9/site-packages/django/apps/registry.py", line 253, in get_containing_app_config
    self.check_apps_ready()
  File "/home/hadi/Documents/first_django_project/venv/lib/python3.9/site-packages/django/apps/registry.py", line 135, in check_apps_ready
    settings.INSTALLED_APPS
  File "/home/hadi/Documents/first_django_project/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/home/hadi/Documents/first_django_project/venv/lib/python3.9/site-packages/django/conf/__init__.py", line 63, in _setup
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are …
Run Code Online (Sandbox Code Playgroud)

python django python-3.x

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×2

django ×1

python-3.x ×1

user-agent ×1