当前设置:
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。在按照各种升级清单中的说明清理了一些明显的内容之后,被卡在了这个似乎无法在任何地方得到回答的内容上。迁移阻碍了某些“统计”模块。可能某些依赖模块不再与升级的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'
谢谢你的建议。
答案 0 :(得分:1)
您可能有一个自定义的statistics
模块,该模块将覆盖标准库提供的模块。重命名自定义statistics
模块以解决该问题。