web-dev-qa-db-fra.com

ne peut pas installer lxml dans virtualenv (python)

Je ne peux pas installer LXML. Dans le système, j’ai le paquet python-lxml, mais j’ai besoin d’autres outils ... Aidez-moi, si vous le pouvez - ma tâche est d’installer lxml pour le développement dans un environnement virtuel en utilisant virtualenv. J'ai trouvé cette solution réparée avec succès installation lxml:

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

Ensuite:

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

Mais j'ai beaucoup de problèmes.

Le premier problème était installer build-essential avec dépendances - pourquoi build-essential a échoué?

C'est résolu! Merci pour ça!

Ensuite, j'ai celui-ci (sortie):

(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

J'ai lu cette instruction http://lxml.de/installation.html et essayez:

STATIC_DEPS=true pip install lxml

J'essaie:

(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)

Je comprends que la raison peut être une variable LANG et essayez ceci:

$ unset LANG

J'ai après (sortie):

(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

Donc, j'essaie d'utiliser easy_install avec STATIC_DEPS = true

J'ai après (sortie):

(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

Alors je suis triste et je ne sais pas quoi faire. Je crois à l'aide de la communauté Stack Exchange.

Désolé pour ma question et l'anglais (ce n'est pas ma langue maternelle).

1
dmgl

Le -lz signifie un fichier de bibliothèque nommé libz.so. Ce fichier est fourni par le package zlib1g-dev. Exécutez Sudo apt-get install zlib1g-dev pour installer le package et relancez la commande d'origine (sans STATIC_DEPS).

9
saiarcot895