django - 使用 pip install 出现异常

标签 django python-2.7 pip ubuntu-14.04

我是 python 新手,并尝试在我在 DigitalOcean 上使用 Ubuntu 14.04 设置的服务器实例上安装我的 django 项目。当我运行命令 sudo pip installrequirements.txt 时,它似乎安装了所有要求,但随后产生以下异常:

running build_ext

building '_cffi_backend' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/c

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DUSE__THREAD -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-x86_64-2.7/c/_cffi_backend.o

c/_cffi_backend.c:13:17: fatal error: ffi.h: No such file or directory

 #include <ffi.h>

                 ^

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-k7f7bu-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/cffi
Storing debug log for failure in /home/myname/.pip/pip.log

我已经检查过,我的开发机器和服务器都安装了相同版本的 python(2.7.6)

更新 运行 I'L'I 下面建议的安装后,我取得了一些进展,但遇到了另一个异常:

running build_ext

building 'gnureadline' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/Modules

creating build/temp.linux-x86_64-2.7/Modules/2.x

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_RL_CALLBACK -DHAVE_RL_CATCH_SIGNAL -DHAVE_RL_COMPLETION_APPEND_CHARACTER -DHAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK -DHAVE_RL_COMPLETION_MATCHES -DHAVE_RL_COMPLETION_SUPPRESS_APPEND -DHAVE_RL_PRE_INPUT_HOOK -I. -I/usr/include/python2.7 -c Modules/2.x/readline.c -o build/temp.linux-x86_64-2.7/Modules/2.x/readline.o

In file included from Modules/2.x/readline.c:31:0:

./readline/readline.h:385:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]

 extern int rl_message ();

 ^

x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/Modules/2.x/readline.o readline/libreadline.a readline/libhistory.a -lncurses -o build/lib.linux-x86_64-2.7/gnureadline.so

/usr/bin/ld: cannot find -lncurses

collect2: error: ld returned 1 exit status

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/gnureadline/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-B2p3jW-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/gnureadline
Storing debug log for failure in /home/juan/.pip/pip.log

最佳答案

您似乎没有安装libffi-dev:

sudo apt-get install libffi-dev

应该安装缺少 header 的软件包。

如果这是一个新服务器,那么您还可以选择立即安装一些更常见的开发包:

sudo apt-get install libffi-dev libssl-dev libxml2-dev libxslt1-dev libncurses5-sdev

关于django - 使用 pip install 出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31508762/

相关文章:

python - Firebase python admin sdk isNewUser ()

python - 安装了 patsy,仍然无法安装 statsmodels

django - 如何更改 django-oscar 仪表板上的货币符号?

django - heroku上的geoDjango

python - TemplateDoesNotExist 位于/index.html

python - 将大文本文件(约 50GB)拆分为多个文件

r - Conda:从github安装R包

python - 为什么 pip 安装包没有出现在 pip freeze 中?

django - 我如何从通用更新 View 中获取我的对象ID以在django 1.1中的表单中使用

python - quickfix 发送时间(字段 52)下降毫秒