【发布时间】:2020-11-24 10:35:28
【问题描述】:
我正在尝试在 Cpanel 上发布我的 django 项目 这是我的网站 (http://qhse-erp.com/)
我用过pip install django==2.1 --use-feature=2020-resolver
安装我所有的包,但出现以下错误:
move_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying authtoken.0001_initial... OK
Applying authtoken.0002_auto_20160226_1747...Traceback (most recent call last):
File "/home/aeraeg/virtualenv/python/3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.SyntaxError: syntax error at or near "WITH ORDINALITY"
LINE 6: FROM unnest(c.conkey) WITH ORDINALITY co...
^
................
File "/home/aeraeg/virtualenv/python/3.7/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/aeraeg/virtualenv/python/3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: syntax error at or near "WITH ORDINALITY"
LINE 6: FROM unnest(c.conkey) WITH ORDINALITY co...
这是我的一些包裹
这是我的安装包列表
Django==2.1
django-appconf==1.0.3
django-autocomplete-light==3.4.1
django-bootstrap-datepicker-plus==3.0.5
django-bootstrap4==1.0.1
django-countries==5.5
django-crispy-forms==1.8.0
django-cruds-adminlte==0.0.16
django-image-cropping==1.2.0
django-modeltranslation==0.13.4
django-rosetta==0.9.3
django-settings-export==1.2.1
django-taggit==1.1.0
django-userforeignkey==0.3.0
djangoajax==3.1
djangorestframework==3.10.3
Pillow==6.2.1
pipenv==2018.11.26
polib==1.1.0
psycopg2-binary==2.8.4
pycodestyle==2.5.0
我收到错误消息 错误:easy-thumbnails 2.6 需要 django=1.8,但您将拥有不兼容的 django 2.2.6。 easy-thumbnails 2.6 需要pillow
但我尝试通过许多版本卸载 django 和 Pillow,但事实并非如此
【问题讨论】:
-
我认为
--use-feature=2020-resolver没有问题。运行pip install后,你可以运行pip freeze查看它安装了什么。 -
回溯显示当您运行
manage.py migrate时发生错误。您是否正在运行不支持WITH ORDINALITY的非常旧的版本或 PostgreSQL? Django 2.1 requires PostgreSQL 9.4+。但是,请注意 Django 2.1.X 现已结束生命周期,因此您应该尽可能升级到最新的 2.2.X LTS 或 3.1.X 版本。 -
psycopg2-binary是用于访问 PostgreSQL 数据库的 Python 包,而不是实际的 PostgreSQL 安装。我对 cPanel 不熟悉,但this thread 建议使用 phpPgAdmin 来检查 PostgreSQL 版本。 -
那是一个非常旧的 PostgreSQL 版本 - Django 1.10 was the last version to support PostgreSQL 9.2
-
请注意,在生产环境中运行
manage.py runserver是不安全的。通常你会使用 Apache + mod_wsgi 或 Nginx + gunicorn 之类的东西。有关详细信息,请参阅deployment docs,或查找分步教程(您可能能够找到专门针对 cPanel 的教程)。