我创建了一个虚拟环境和一个新的空白 django 项目。我想安装 Channels。我使用的是 Python 3.6.3。我输入了pip install -U channels
以下内容,输出如下:
...
Failed building wheel for twisted
...
Command "/home/marcin/Documents/django_projects/channels/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ic8ux9ei/twisted/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-ox6bclm5-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/marcin/Documents/django_projects/channels/include/site/python3.6/twisted" failed with error code 1 in /tmp/pip-build-ic8ux9ei/twisted/
pip list
输出:
...
Django (1.11.6)
...
pip (9.0.1)
...
setuptools (36.6.0)
...
wheel (0.29.0)
...
我发现我没有 Twisted,所以我输入:pip install twisted
。这是输出:
...
Failed building wheel for twisted
...
Command "/home/marcin/Documents/django_projects/channels/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-a54n37_z/twisted/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-9p23ehnv-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/marcin/Documents/django_projects/channels/include/site/python3.6/twisted" failed with error code 1 in /tmp/pip-build-a54n37_z/twisted/
如您所见,输出几乎相同。如何安装频道?
答案1
该错误消息不是特别有用,但似乎您缺少python3.6-dev
使用以下命令安装的包apt
:
sudo apt update
sudo apt install python3.6-dev
此后,像以前一样使用 pip 重复安装。
答案2
build-essential
如果尚未安装该软件包,您还需要安装它。完整的安装命令是:
sudo apt-get install build-essential python3.6-dev
答案3
安装 rasa_core 时遇到类似的问题。
通过几个步骤解决了一个问题:
sudo apt-get update
sudo apt-get install build-esssential python3.6-dev
最终能够成功安装rasa_core。