1

I cannot install lxml. In system i have python-lxml package, but i need other... Please help, if you can - my task is install lxml for development in virtual enviroment using virtualenv. I found this solution repaired successfully installation lxml:

$ sudo apt-get install libxml2 libxml2-dev libxslt-dev build-essential python-dev
$ sudo ldconfig

Then:

$ source bin/activate # for activate enviroment
(env) $ pip install lxml

But i have many problems.

First problem was install build-essential with dependencies - why build-essential failed?

It solved! Thanks for it!

Next i have this one (output):

(env) $ pip install lxml

...

i686-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-i686-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-i686-2.7/lxml/etree.so

/usr/bin/ld: cannot find -lz

collect2: error: ld returned 1 exit status

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

----------------------------------------
Cleaning up...
Command /tmp/1/bin/python -c "import setuptools, tokenize;__file__='/tmp/1/build/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-DpYhbY-record/install-record.txt --single-version-externally-managed --compile --install-headers /tmp/1/include/site/python2.7 failed with error code 1 in /tmp/1/build/lxml
Storing debug log for failure in /home/constantia/.pip/pip.log

I read this instruction http://lxml.de/installation.html and try:

STATIC_DEPS=true pip install lxml

I try:

(env) $ STATIC_DEPS=true pip install lxml

...


  File "buildlibxml.py", line 268, in call_subprocess

    raise Exception('Command "%s" returned code %s' % (cmd_desc, returncode))

Exception: Command "make -j3" returned code 512

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/1/build/lxml
Traceback (most recent call last):
  File "/tmp/1/bin/pip", line 11, in <module>
    sys.exit(main())
  File "/tmp/1/local/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    return command.main(cmd_args)
  File "/tmp/1/local/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 13: ordinal not in range(128)

I understand that reason may be LANG variables and try this:

$ unset LANG

I have after (output):

(env) $ STATIC_DEPS=true pip install lxml

...

  File "buildlibxml.py", line 268, in call_subprocess

    raise Exception('Command "%s" returned code %s' % (cmd_desc, returncode))

Exception: Command "make -j3" returned code 512

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/1/build/lxml
Storing debug log for failure in /home/constantia/.pip/pip.log

So, i try to use easy_install with STATIC_DEPS=true

I have after (output):

(env) $ STATIC_DEPS=true pip install lxml

...

make[2]: *** [progname.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/tmp/easy_install-bqh5aG/lxml-3.3.5/build/tmp/libiconv-1.14/srclib'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/tmp/easy_install-bqh5aG/lxml-3.3.5/build/tmp/libiconv-1.14/srclib'
make: *** [all] Error 2
Traceback (most recent call last):
  File "/tmp/1/bin/easy_install", line 11, in <module>
    sys.exit(main())
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1909, in main
    with_ei_usage(lambda:
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1896, in with_ei_usage
    return f()
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1913, in <lambda>
    distclass=DistributionWithoutHelpCommands, **kw
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 358, in run
    self.easy_install(spec, not self.no_deps)
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 593, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 623, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 809, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1015, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1000, in run_setup
    run_setup(setup_script, args)
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 50, in run_setup
    lambda: execfile(
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 100, in run
    return func()
  File "/tmp/1/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 52, in <lambda>
    {'__file__':setup_script, '__name__':'__main__'}
  File "setup.py", line 229, in <module>
  File "setup.py", line 140, in setup_extra_options
  File "/tmp/easy_install-bqh5aG/lxml-3.3.5/setupinfo.py", line 57, in ext_modules
  File "/tmp/easy_install-bqh5aG/lxml-3.3.5/buildlibxml.py", line 348, in build_libxml2xslt
  File "/tmp/easy_install-bqh5aG/lxml-3.3.5/buildlibxml.py", line 285, in cmmi
  File "/tmp/easy_install-bqh5aG/lxml-3.3.5/buildlibxml.py", line 268, in call_subprocess
Exception: Command "make -j3" returned code 512

So i sad and don't know what to do. I believe for help from Stack Exchange community.

Sorry for my question and English (it's not my native language).

1 Answer 1

9

The -lz means a library file named libz.so. This file is provided by the zlib1g-dev package. Run sudo apt-get install zlib1g-dev to install the package, and try your original command again (without STATIC_DEPS).

3
  • 1
    Thank you very much! pip install lxml, after sudo apt-get install zlib1g-dev solve my problem at all. How do you determine that this command solve the problem? Is it your own experience or i could find something about it... i mean -lz. I am trying not to make stupid questions in future...
    – dmgl
    Jun 25, 2014 at 20:29
  • The -l flag refers to a library, and the name after -l is the name of the library (without the lib prefix), so -lsomething refers to a library file named libsomething.so. In this case, the library is libz.so. Usually, you know what the library is and can just do apt-get install something-dev or the appropriate package name, but this is one of those exceptions. apt-file helped identify the package. Jun 25, 2014 at 20:38
  • 1
    Than you very-very much!
    – dmgl
    Jun 27, 2014 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.