não pode instalar o lxml em virtualenv (python)

1

Não consigo instalar o lxml. No sistema eu tenho o pacote python-lxml, mas eu preciso de outro ... Por favor, ajudem, se você puder - minha tarefa é instalar o lxml para desenvolvimento em ambiente virtual usando virtualenv. Eu encontrei esta solução consertada com sucesso instalação lxml:

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

Então:

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

Mas tenho muitos problemas.

O primeiro problema foi instalar o build-essential com dependências - por que o build-essential falhou?

Solucionado! Obrigado por isso!

A seguir eu tenho este (saída):

(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

Eu li esta instrução link e tente:

STATIC_DEPS=true pip install lxml

Eu tento:

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

Eu entendo que o motivo pode ser variáveis LANG e tente isto:

$ unset LANG

Eu tenho depois (saída):

(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

Então, eu tento usar easy_install com STATIC_DEPS = true

Eu tenho depois (saída):

(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

Então eu estou triste e não sei o que fazer. Eu acredito em ajuda da comunidade do Stack Exchange.

Desculpe pela minha pergunta e pelo inglês (não é minha língua nativa).

    
por dmgl 19.06.2014 / 21:56

1 resposta

9

O -lz significa um arquivo de biblioteca denominado libz.so . Este arquivo é fornecido pelo pacote zlib1g-dev . Execute sudo apt-get install zlib1g-dev para instalar o pacote e tente seu comando original novamente (sem STATIC_DEPS ).

    
por saiarcot895 19.06.2014 / 22:03