【问题标题】:Error occurs when Install scrapy in python virtualenv use pip在 python virtualenv 中使用 pip 安装 scrapy 时发生错误
【发布时间】:2017-12-21 05:55:39
【问题描述】:

系统信息:

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

我首先在ubuntu中安装virtualenv

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 ubuntu scrapy pip


【解决方案1】:

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

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

【讨论】:

  • 运行后出现此错误sudo apt-get install python-dev :The following packages have unmet dependencies: python-dev : Depends: python (= 2.7.5-5ubuntu3) but 2.7.8-1 is to be installed Depends: libpython-dev (= 2.7.5-5ubuntu3) but it is not going to be installed Depends: python2.7-dev (>= 2.7.5-1~) but it is not going to be installed E: Unable to correct problems, you have held broken packages.
  • 先尝试更新python
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-08-18
  • 2016-07-12
  • 2018-10-14
  • 1970-01-01
  • 2018-01-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多