首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >升级到Django2.2: AttributeError:模块'statistics‘没有属性'pstdev’

升级到Django2.2: AttributeError:模块'statistics‘没有属性'pstdev’
EN

Stack Overflow用户
提问于 2019-05-02 16:48:06
回答 1查看 1.7K关注 0票数 3

当前设置:

Python 3.6

代码语言:javascript
复制
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。在清理了各种升级检查表中描述的一些明显的东西后,我被这个问题卡住了,这个问题似乎在任何地方都没有答案。迁移在一些“统计”模块上遇到了瓶颈。可能一些依赖模块与升级的Django不再兼容:

正在尝试:

代码语言:javascript
复制
> python manage.py runserver

获取:

代码语言:javascript
复制
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'

完整的回溯:

代码语言:javascript
复制
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'

谢谢你的建议。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-02 17:42:12

您可能有一个自定义的statistics模块,它覆盖了标准库提供的模块。重命名自定义statistics模块以修复此问题。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55948758

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档