python - 在 python virtualenv 中使用 pip 安装 scrapy 时发生错误

标签 python ubuntu scrapy pip

系统信息 :

Ubuntu 14.10
Linux vagrant-ubuntu-trusty 3.16.0-23-generic #31-Ubuntu SMP Tue Oct 21 17:56:17 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

我先安装virtualenv在ubuntu中
sudo pip install virtualenv
virtualenv scrapy-env
cd scrapy-env/
source bin/activate
pip install scrapy

然后我得到这个错误:
  running build_ext
    building 'twisted.test.raiser' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/src
    creating build/temp.linux-x86_64-2.7/src/twisted
    creating build/temp.linux-x86_64-2.7/src/twisted/test
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-2.7/src/twisted/test/raiser.o
    src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/vagrant/pyenv/scrapy-env/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-NJKTtN/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-_i2ueH-record/install-record.txt --single-version-externally-managed --compile --install-headers /vagrant/pyenv/scrapy-env/include/site/python2.7/Twisted" failed with error code 1 in /tmp/pip-build-NJKTtN/Twisted/

有什么建议可以帮助我解决它吗?

最佳答案

您没有安装 Python 开发人员包。尝试安装它们

sudo apt-get install python-dev # for python2.x installs
sudo apt-get install python3-dev  # for python3.x installs

关于python - 在 python virtualenv 中使用 pip 安装 scrapy 时发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47918761/

相关文章:

python - 启用 scrapy 记录器时如何查看打印语句的输出

python - 仅限 Scrapy 正文

python - Python 给函数参数赋值的过程是怎样的?

python - 我想检查Python的子进程是否成功或者是否发生错误

python - ImportError : libta_lib. so.0: 无法打开共享对象文件: 没有这样的文件或目录

python - 搞砸了 numpy 安装 - `GFORTRAN_1.4' 未找到错误

ubuntu - 如何关闭 Sublime 2 更新通知?

xpath - 网络抓取-从bandcamp.com获取项目标题

python - MD5摘要在不同系统之间是否一致?

python - numpy 中数组的有界和或差