简体   繁体   English

lxml 永远不会在 ubuntu 上完成构建

[英]lxml will never finish building on ubuntu

I am running ubuntu 14.04 LTS and python 2.7.5 on a vwmare.我在 vwmare 上运行 ubuntu 14.04 LTS 和 python 2.7.5。

When I run:当我运行时:

sudo pip install lxml

I get:我得到:

Collecting lxml
  Using cached lxml-3.4.4.tar.gz
Building wheels for collected packages: lxml
  Running setup.py bdist_wheel for lxml

which runs eternally.永远运行。

I can't find any resources related to this, nor do I have any experience with similar errors.我找不到与此相关的任何资源,也没有任何类似错误的经验。

Note, the solution below does not work:请注意,以下解决方案不起作用:

sudo apt-get build-dep -y lxml;
pip install lxml

I have also tried:我也试过:

sudo apt-get install -y build-essential python-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version.
python-dev is already the newest version.
The following packages were automatically installed and are no longer required:
  linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic
  linux-headers-3.13.0-57 linux-headers-3.13.0-57-generic
  linux-image-3.13.0-32-generic linux-image-3.13.0-57-generic
  linux-image-extra-3.13.0-32-generic linux-image-extra-3.13.0-57-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 75 not upgraded.

EDIT:编辑:

I just ran it again and got:我再次运行它并得到:

sudo pip install lxml

Collecting lxml
/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Using cached lxml-3.4.4.tar.gz
Building wheels for collected packages: lxml
  Running setup.py bdist_wheel for lxml

EDIT 2:编辑2:

 pip install lxml

The directory '/home/myusername/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/myusername/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting lxml
/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading lxml-3.4.4.tar.gz (3.5MB)
    100% |████████████████████████████████| 3.5MB 7.0kB/s 
Installing collected packages: lxml
  Running setup.py install for lxml

EDIT 3: After waiting a long time the command gave:编辑 3:等待很长时间后,命令给出:

pip install lxml
The directory '/home/mstaffel/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/mstaffel/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting lxml
/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading lxml-3.4.4.tar.gz (3.5MB)
    100% |████████████████████████████████| 3.5MB 7.0kB/s 
Installing collected packages: lxml
  Running setup.py install for lxml
    Complete output from command /usr/local/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-u3iJ67/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-0tAWPp-record/install-record.txt --single-version-externally-managed --compile:
    /usr/local/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.4.4.
    Building without Cython.
    Using build configuration of libxslt 1.1.28
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-i686-2.7
    creating build/lib.linux-i686-2.7/lxml
    copying src/lxml/pyclasslookup.py -> build/lib.linux-i686-2.7/lxml
    copying src/lxml/cssselect.py -> build/lib.linux-i686-2.7/lxml
    copying src/lxml/__init__.py -> build/lib.linux-i686-2.7/lxml
    copying src/lxml/_elementpath.py -> build/lib.linux-i686-2.7/lxml
    copying src/lxml/doctestcompare.py -> build/lib.linux-i686-2.7/lxml
    copying src/lxml/builder.py -> build/lib.linux-i686-2.7/lxml
    copying src/lxml/ElementInclude.py -> build/lib.linux-i686-2.7/lxml
    copying src/lxml/usedoctest.py -> build/lib.linux-i686-2.7/lxml
    copying src/lxml/sax.py -> build/lib.linux-i686-2.7/lxml
    creating build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/__init__.py -> build/lib.linux-i686-2.7/lxml/includes
    creating build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/__init__.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/_diffcommand.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/soupparser.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/builder.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/usedoctest.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/html5parser.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/_setmixin.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/_html5builder.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/defs.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/clean.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/ElementSoup.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/diff.py -> build/lib.linux-i686-2.7/lxml/html
    copying src/lxml/html/formfill.py -> build/lib.linux-i686-2.7/lxml/html
    creating build/lib.linux-i686-2.7/lxml/isoschematron
    copying src/lxml/isoschematron/__init__.py -> build/lib.linux-i686-2.7/lxml/isoschematron
    copying src/lxml/lxml.etree.h -> build/lib.linux-i686-2.7/lxml
    copying src/lxml/lxml.etree_api.h -> build/lib.linux-i686-2.7/lxml
    copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/tree.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/schematron.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/xinclude.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/c14n.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/xpath.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/xslt.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/uri.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/relaxng.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/config.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/etree_defs.h -> build/lib.linux-i686-2.7/lxml/includes
    copying src/lxml/includes/lxml-version.h -> build/lib.linux-i686-2.7/lxml/includes
    creating build/lib.linux-i686-2.7/lxml/isoschematron/resources
    creating build/lib.linux-i686-2.7/lxml/isoschematron/resources/rng
    copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/rng
    creating build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl
    copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl
    creating build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-i686-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
    running build_ext
    building 'lxml.etree' extension
    creating build/temp.linux-i686-2.7
    creating build/temp.linux-i686-2.7/src
    creating build/temp.linux-i686-2.7/src/lxml
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-u3iJ67/lxml/src/lxml/includes -I/usr/local/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-i686-2.7/src/lxml/lxml.etree.o -w
    gcc -pthread -shared build/temp.linux-i686-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-i686-2.7/lxml/etree.so
    building 'lxml.objectify' extension
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-u3iJ67/lxml/src/lxml/includes -I/usr/local/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.linux-i686-2.7/src/lxml/lxml.objectify.o -w
    gcc -pthread -shared build/temp.linux-i686-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-i686-2.7/lxml/objectify.so
    running install_lib
    creating /usr/local/lib/python2.7/site-packages/lxml
    error: could not create '/usr/local/lib/python2.7/site-packages/lxml': Permission denied

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

Note that if you run top in a separate terminal you'll notice that your system is busy building the lxml package:请注意,如果您在单独的终端中运行top ,您会注意到您的系统正忙于构建lxml包:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1645 root 20 0 322224 305740 5384 R 100.0 29.8 3:27.47 /usr/lib/gcc/arm-linux-gnueabihf/5/cc1 -quiet -I /usr/include/libxml2 -I src/lxml/includes -I /usr/include/python2.7 -imultiarch arm-linux-gnueabihf -D_REENTRANT -D ...

If you're building on a VM or SBC with limited resources this can take a while...如果您在资源有限的 VM 或 SBC 上构建,这可能需要一段时间......

I ran this on VM with 768MB ram (which i didn't notice was the value i set) and it took several hours and didn't finish.我在具有 768MB ram 的 VM 上运行此程序(我没有注意到这是我设置的值),并且花了几个小时并没有完成。

Changing ram to 3GB made it finish in few minutes after restarting and trying again.将 ram 更改为 3GB 使其在重新启动并重试后几分钟内完成。

I ran into the same problem when trying to "pip install" a package that depends on lxml on a Raspberry Pi 1 B+.我在尝试“pip install”一个依赖于 Raspberry Pi 1 B+ 上的 lxml 的包时遇到了同样的问题。 After several hours (and several attempts), the SSH connection dropped without finishing the wheel build.几个小时(和几次尝试)后,SSH 连接在没有完成轮子构建的情况下就断开了。 It seems like an out-of-memory situation.这似乎是内存不足的情况。

I opted on installing the pre-built binary packages using apt install python-lxml or apt install python3-lxml respectively.我选择分别使用apt install python-lxmlapt install python3-lxml安装预先构建的二进制包。

The newest version of pip, unnecessarily spends excessive amount of time to build wheels and resolve dependency issues while building a package with requirements.txt or a setuptools/distutils setup.py最新版本的 pip,在使用 requirements.txt 或 setuptools/distutils setup.py 构建包时,不必要地花费过多时间来构建轮子并解决依赖问题

A quick fix is to revert to a version of pip prior to 21.0 (ideally in a virtual environment), where the legacy resolver is still supported, according to this discussion:sunsetting legacy resolver根据此讨论,快速修复是恢复到 21.0 之前的 pip 版本(理想情况下在虚拟环境中),其中仍然支持旧式解析器suntingting legacy resolver

As of July 28th, 2021 pip v21.2.1 still seems to have the legacy resolver support.截至 2021 年 7 月 28 日,pip v21.2.1 似乎仍然支持旧版解析器。

pip install pip==20.2.4

Command below uses an earlier version of dependency resolver to install lxml.下面的命令使用早期版本的依赖解析器来安装 lxml。

pip install --use-deprecated=legacy-resolver lxml

Saved me a lot of time and hassle.为我节省了很多时间和麻烦。

I think you should to install cython.我认为你应该安装cython。 As I can see in your code it is said that: Building without Cython.正如我在您的代码中看到的那样:在Building without Cython. and if we go to pypi and look up for lxml it is said that Note that this requires Cython to build the sources, see the build instructions on the project home page.如果我们去 pypi 并查找 lxml 据说注意这需要 Cython 来构建源代码,请参阅项目主页上的构建说明。 Here is the link: lxml这是链接: lxml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM