gpt4 book ai didi

django - 升级到 Django 2.2 : AttributeError: module 'statistics' has no attribute 'pstdev'

转载 作者:行者123 更新时间:2023-12-04 14:20:02 25 4
gpt4 key购买 nike

当前设置:

python 3.6

Django==2.2
gunicorn==19.1.0
coverage==4.4.1
django-suit==0.2.26
django-extensions==2.0.6
djangorestframework==3.8.2
djangorestframework-datatables==0.3.0
djangorestframework-csv==2.1.0
coreapi==2.3.3
Faker==0.9.0
pillow==5.2.0
simple-crypt==4.1.7
xlrd==1.1.0
django-crequest==2018.5.11
gitpython==2.1.11
django_icons==0.2.1

将 Django 从 1.11 升级到 2.2。在清理了各种升级 list 中描述的一些明显的东西之后,卡在了这个似乎没有任何地方回答的问题上。迁移在某些“统计”模块上阻塞。可能某些依赖模块不再与升级后的 Django 兼容:

试:
> python manage.py runserver

获得:
File "/Users/myuser/.local/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 230, in get_new_connection
conn.create_aggregate('STDDEV_POP', 1, list_aggregate(statistics.pstdev))
AttributeError: module 'statistics' has no attribute 'pstdev'

完整的追溯:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/Users/myuser/miniconda3/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/Users/myuser/miniconda3/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/Users/myuser/.local/lib/python3.5/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/Users/myuser/.local/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
self.check_migrations()
File "/Users/myuser/.local/lib/python3.5/site-packages/django/core/management/base.py", line 453, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/Users/myuser/.local/lib/python3.5/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/Users/myuser/.local/lib/python3.5/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/Users/myuser/.local/lib/python3.5/site-packages/django/db/migrations/loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/Users/myuser/.local/lib/python3.5/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
if self.has_table():
File "/Users/myuser/.local/lib/python3.5/site-packages/django/db/migrations/recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/Users/myuser/.local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 256, in cursor
return self._cursor()
File "/Users/myuser/.local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 233, in _cursor
self.ensure_connection()
File "/Users/myuser/.local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/Users/myuser/.local/lib/python3.5/site-packages/django/db/backends/base/base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "/Users/myuser/.local/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 230, in get_new_connection
conn.create_aggregate('STDDEV_POP', 1, list_aggregate(statistics.pstdev))
AttributeError: module 'statistics' has no attribute 'pstdev'

谢谢你的建议。

最佳答案

您可能有一个自定义 statistics覆盖标准库提供的模块。重命名自定义 statistics模块来解决问题。

关于django - 升级到 Django 2.2 : AttributeError: module 'statistics' has no attribute 'pstdev' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55948758/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com