首页 > 解决方案 > django频道安装错误

问题描述

我正在尝试使用 Django 创建一个一对一的实时消息传递系统。经过搜索,我发现了关于django-channels. 所以我用 python 3.5 和最新的 Django 创建了一个虚拟环境,但是当我这样做时,pip install channels我得到:

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/home/kshitij/Documents/projects/personal/maker/venv/include/python3.5m -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-3.5/src/twisted/test/raiser.o

 #include "Python.h"
                    ^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

可能是因为缺少 python 标头所以我这样做了:sudo apt-get install python3-dev但它仍然显示相同的错误。我应该怎么办?

pip version:    18
python version: 3.5
django version: 2.1

我尝试做sudo apt-get install python3-dev但得到:

 ImportError: cannot import name '_BACKCOMPAT_MAGIC_NUMBER'

标签: djangopython-3.5django-channels

解决方案


  1. 验证您的pipis notpip及其pip3.
  2. 您也可以尝试安装sudo apt install python3.X-dev.

对你来说是sudo apt install python3.5-dev


推荐阅读