【问题标题】:Installing lxml with enthought Python on Amazon ec2 ubuntu instance在 Amazon ec2 ubuntu 实例上使用 enthought Python 安装 lxml
【发布时间】:2013-03-21 09:19:28
【问题描述】:

我在 ubuntu 上成功安装了 enthought Python(在 Amazon EC2 实例中运行)。但是,尝试安装 lxml 包时出现以下错误(已插入日志)

/usr/local/bin/pip run on Sat Mar 30 22:05:14 2013
Downloading/unpacking lxml

Running setup.py egg_info for package lxml

/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

 warnings.warn(msg)

 Building lxml version 3.1.1.

 Building without Cython.

 Using build configuration of libxslt 1.1.26

 Building against libxml2/libxslt in the following directory: /usr/lib/x86_64-linux-gnu

 running egg_info
 writing pip-egg-info/lxml.egg-info/PKG-INFO
 writing top-level names to pip-egg-info/lxml.egg-info/top_level.txt
 writing dependency_links to pip-egg-info/lxml.egg-info/dependency_links.txt
 warning: manifest_maker: standard file '-c' not found


 reading manifest file 'pip-egg-info/lxml.egg-info/SOURCES.txt'
 reading manifest template 'MANIFEST.in'
 warning: no files found matching '*.txt' under directory 'src/lxml/tests'

 writing manifest file 'pip-egg-info/lxml.egg-info/SOURCES.txt'
 Source in /tmp/pip-build-root/lxml has version 3.1.1, which satisfies requirement lxml
 Installing collected packages: lxml

 Running setup.py install for lxml

Running command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-1bVipz-record/install-record.txt --single-version-externally-managed
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

warnings.warn(msg)

Building lxml version 3.1.1.

Building without Cython.

Using build configuration of libxslt 1.1.26

Building against libxml2/libxslt in the following directory: /usr/lib/x86_64-linux-gnu

running install
running build
running build_py
copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-2.7/lxml/includes
running build_ext
building 'lxml.etree' extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-root/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o

src/lxml/lxml.etree.c: In function ‘__pyx_f_4lxml_5etree__getFilenameForFile’:

src/lxml/lxml.etree.c:26852:7: warning: variable ‘__pyx_clineno’ set but not used [-Wunused-but-set-variable]

src/lxml/lxml.etree.c:26851:15: warning: variable ‘__pyx_filename’ set but not used [-Wunused-but-set-variable]

src/lxml/lxml.etree.c:26850:7: warning: variable ‘__pyx_lineno’ set but not used [-Wunused-but-set-variable]

src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_4XSLT_18__call__’:

src/lxml/lxml.etree.c:138240:81: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_12_XSLTContext__copy’ from incompatible pointer type [enabled by default]

src/lxml/lxml.etree.c:136196:52: note: expected ‘struct __pyx_obj_4lxml_5etree__XSLTContext *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__BaseContext *’

src/lxml/lxml.etree.c: In function ‘__pyx_f_4lxml_5etree__copyXSLT’:

src/lxml/lxml.etree.c:139634:79: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_12_XSLTContext__copy’ from incompatible pointer type [enabled by default]

src/lxml/lxml.etree.c:136196:52: note: expected ‘struct __pyx_obj_4lxml_5etree__XSLTContext *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__BaseContext *’

src/lxml/lxml.etree.c: At top level:

src/lxml/lxml.etree.c:12385:13: warning: ‘__pyx_f_4lxml_5etree_displayNode’ defined but not used [-Wunused-function]

gcc: internal compiler error: Killed (program cc1)

Please submit a full bug report,

with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.

error: command 'gcc' failed with exit status 4

Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-1bVipz-record/install-record.txt --single-version-externally-managed:

/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

warnings.warn(msg)

Building lxml version 3.1.1.

Building without Cython.

Using build configuration of libxslt 1.1.26

Building against libxml2/libxslt in the following directory: /usr/lib/x86_64-linux-gnu

running install

running build

running build_py

copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-2.7/lxml/includes

running build_ext

building 'lxml.etree' extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-root/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o

src/lxml/lxml.etree.c: In function ‘__pyx_f_4lxml_5etree__getFilenameForFile’:

src/lxml/lxml.etree.c:26852:7: warning: variable ‘__pyx_clineno’ set but not used [-Wunused-but-set-variable]

src/lxml/lxml.etree.c:26851:15: warning: variable ‘__pyx_filename’ set but not used [-Wunused-but-set-variable]

src/lxml/lxml.etree.c:26850:7: warning: variable ‘__pyx_lineno’ set but not used [-Wunused-but-set-variable]

src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_4XSLT_18__call__’:

src/lxml/lxml.etree.c:138240:81: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_12_XSLTContext__copy’ from incompatible pointer type [enabled by default]

src/lxml/lxml.etree.c:136196:52: note: expected ‘struct __pyx_obj_4lxml_5etree__XSLTContext *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__BaseContext *’

src/lxml/lxml.etree.c: In function ‘__pyx_f_4lxml_5etree__copyXSLT’:

src/lxml/lxml.etree.c:139634:79: warning: passing argument 1 of ‘__pyx_f_4lxml_5etree_12_XSLTContext__copy’ from incompatible pointer type [enabled by default]

src/lxml/lxml.etree.c:136196:52: note: expected ‘struct __pyx_obj_4lxml_5etree__XSLTContext *’ but argument is of type ‘struct __pyx_obj_4lxml_5etree__BaseContext *’

src/lxml/lxml.etree.c: At top level:

src/lxml/lxml.etree.c:12385:13: warning: ‘__pyx_f_4lxml_5etree_displayNode’ defined but not used [-Wunused-function]

gcc: internal compiler error: Killed (program cc1)

Please submit a full bug report,

with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.

error: command 'gcc' failed with exit status 4

Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-1bVipz-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-root/lxml

Exception information:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 139, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 271, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 1185, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 592, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "/usr/local/lib/python2.7/dist-packages/pip/util.py", line 662, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-1bVipz-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-root/lxml

【问题讨论】:

    标签: python ubuntu amazon-ec2 lxml enthought


    【解决方案1】:

    我在我的实例上发现了同样的问题。原来是编译lxml会占用大量内存,而我的实例内存不足,所以内核正在杀死编译器。

    要检查您是否有同样的问题,请尝试在失败后运行dmesg|tail。你会看到一些类似的行:

    [2242482.581361] Out of memory: Kill process 8306 (cc1) score 432 or sacrifice child
    [2242482.581375] Killed process 8306 (cc1) total-vm:298572kB, anon-rss:260756kB, file-rss:4kB
    

    【讨论】:

    • 你是如何解决这个问题的?是否有安装lxml 的解决方法?
    【解决方案2】:

    要在AWS 微实例中安装lxml,请尝试按照以下步骤操作:

    sudo yum install python-devel
    sudo yum install libxml2-devel
    sudo yum install libxslt-devel  
    sudo yum install gcc        
    sudo easy_install pip
    sudo pip install lxml
    

    请记住,亚马逊只保留了一些可供安装的选定文件,有时名称不同。如果您寻找:

    yum info python-dev
    

    你会发现只是一个错误:

    Error: No matching Packages to list
    

    但是……

    yum info python-devel
    

    将显示您需要的内容

    Name        : python-devel
    Arch        : noarch
    Epoch       : 1
    Version     : 2.6
    Release     : 2.26.amzn1
    Size        : 0.0  
    Repo        : installed
    From repo   : amzn-main
    Summary     : The libraries and header files needed for Python
                : development.
    URL         : http://www.python.org/
    License     : PSF
    Description : This is a macro package that pulls in via
                : dependencies the system default python development
                : extensions.
    

    【讨论】:

    • 你的问题和问题到底是什么?看来您至少知道如何解决一个问题。
    【解决方案3】:

    要编译 lxml,您需要先安装几个开发库。在 Ubuntu 上,您可以通过以下方式安装它们:

    sudo apt-get install libxml2-dev libxslt-dev
    

    【讨论】:

      【解决方案4】:

      补充丹尼尔的答案,除了安装libxslt-devel、python-devel、libxml2-devel

      sudo yum groupinstall -y development
      sudo yum install libxslt-devel, python-devel, libxml2-devel
      

      如果你收到这样的消息:

      [2242482.581361] Out of memory: Kill process 8306 (cc1) score 432 or sacrifice child 
      [2242482.581375] Killed process 8306 (cc1) total-vm:298572kB, anon-rss:260756kB, file-rss:4kB
      

      您可以创建一个交换文件来补充您的内存,例如添加 512Mb 的交换文件:

      sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
      sudo mkswap /swapfile
      sudo swapon /swapfile
      compile lxml
      

      来源:遇到了这个问题,终于解决了。

      【讨论】:

        猜你喜欢
        • 2014-06-26
        • 1970-01-01
        • 1970-01-01
        • 2014-02-07
        • 2015-04-04
        • 1970-01-01
        • 2020-11-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多