我现在已经完全安装了Django v1.11.10。当我运行python manage.py runserver
时,一切正常。但是当我尝试连接到Postgres数据库时,我安装了包pip install psycopg2
,修改了DATABASES
varibale,在运行runserver
命令后,它失败了,并出现了Illegal instruction
错误:
Performing system checks...
System check identified no issues (0 silenced).
Illegal instruction: 4
这是什么?如何获取日志错误?我使用macos10.11.6,PostgresApp(尝试在v9和v10服务器上检查错误源)。python3.6.4(通过virtualenv)。在
^{pr2}$如果我设置NAME
或USER
不正确,或者即使我关闭,错误也是一样的Postgres.app网站服务器。就像Django看不到Postgres。但是使用phpPgAdmin
我可以连接到Postgres服务器。在
用
pip install no-binary psycopg2 psycopg2
重新安装解决了问题Blender's answer和this other question指出了问题,但是在运行建议的命令时,我得到了以下错误:
由于我对设置、配置等没有任何线索,所以花了一段时间才找到如何做。这是为了防止其他人面临同样的问题:
then
^{pr2}$那么
这就解决了我的问题。在
psycopg2
部分是用C编写的,需要编译。当您pip install
一个包时,通常有一个预编译的二进制轮子可供下载。在由于某些原因,预编译的
psycopg2
模块包含CPU无法识别的指令(可能是因为处理器太旧)。您可以通过自己编译模块来解决此问题,这将确保代码在CPU上正常工作:
^{pr2}$no-binary psycopg2
是一个单独的选项,因此必须指定两次包名。您也可以在您的requirements.txt
中包含此内容:相关问题 更多 >
编程相关推荐