2014-10-10 80 views
6

這是我用來安裝lxml的命令來安裝LXML:失敗使用PIP

sudo pip install lxml 

而且我得到了在清理階段出現以下消息:

Cleaning up... 
Command /usr/bin/python -c "import setuptools,  tokenize;__file__='/private/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-rUFjFN-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/lxml 
Storing debug log for failure in /Users/georgejor/Library/Logs/pip.log 

在那之後,我得到了:

ImportError: No module named lxml 

請幫忙。謝謝!

下面的輸出是從pip.log:

---------------------------------------- 
Cleaning up... 
    Removing temporary dir /private/tmp/pip_build_root... 
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-rUFjFN-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/lxml 
Exception information: 
Traceback (most recent call last): 
    File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 122, in main 
    status = self.run(options, args) 
    File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 283, in run 
    requirement_set.install(install_options, global_options, root=options.root_path) 
    File "/Library/Python/2.7/site-packages/pip/req.py", line 1435, in install 
    requirement.install(install_options, global_options, *args, **kwargs) 
    File "/Library/Python/2.7/site-packages/pip/req.py", line 706, in install 
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False) 
    File "/Library/Python/2.7/site-packages/pip/util.py", line 697, in call_subprocess 
    % (command_desc, proc.returncode, cwd)) 
InstallationError: Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-rUFjFN-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/lxml 
+0

這意味着'lxml'沒有正確安裝。做這個'cat/Users/georgejor/Library/Logs/pip.log'並在問題中向我們展示。 – 2014-10-10 03:17:50

+0

好吧,我剛剛添加。希望它可以幫助。 – 2014-10-10 03:21:01

+0

看起來你沒有安裝setuptools。使用'pip install setuptools'安裝setuptools – 2014-10-10 03:21:50

回答

0

LXML已丙depenedencies,我常常遇到的問題時,我的思念libxsltlibxml2。你確定安裝了所有非python依賴項嗎?

+0

我在Linux上,試圖安裝llvmlite,這並沒有爲我工作 – gota 2015-04-23 16:24:08

11

只要安裝這些東西:

sudo apt-get install libxml2-dev libxslt-dev python-dev python-setuptools 

然後再試一次:

pip install lxml 
+0

這工作對我來說。雖然一味地複製各種程序安裝我不知道是不是一個好主意,但它確實工作:-) – Martin 2015-11-02 00:19:41