gpt4 book ai didi

python - pip lxml 安装段错误

转载 作者:太空宇宙 更新时间:2023-11-04 03:56:40 25 4
gpt4 key购买 nike

运行 Python 2.7.5 和 OSX 10.8。还在使用 Anaconda 包管理器创建的虚拟环境中运行 Python。我已经安装了命令行工具的 XCode 4.6.3。

摆弄 scraperwiki 示例:

import scraperwiki
html = scraperwiki.scrape('https://scraperwiki.com/hello_world.html')
import lxml.cssselect
import lxml.html
root = lxml.html.fromstring(html) # turn our HTML into an lxml object
tds = root.cssselect('td') # get all the <td> tags
for td in tds:
print lxml.html.tostring(td) # the full HTML tag
print td.text # just the text inside the HTML tag

尝试使用 lxml.cssselect 会引发此错误:

/Users/mmoncrief/anaconda/envs/py27/lib/python2.7/site-packages/lxml/cssselect.py in <module>()
16 external_cssselect = __import__('cssselect')
17 except ImportError:
---> 18 raise ImportError('cssselect seems not to be installed. '
19 'See http://packages.python.org/cssselect/')
20

ImportError: cssselect seems not to be installed. See http://packages.python.org/cssselect/

使用 IPython,我在 lxml 下查找已安装的模块(键入 lxml。)并仅找到 lxml.etree 和 lxml.get_include:没有 cssselect 模块。

我尝试使用 pip install lxml --update 更新 lxml。这回馈:

Running setup.py egg_info for package lxml
/Users/mmoncrief/anaconda/envs/py27/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.2.3.
Building without Cython.
Using build configuration of libxslt 1.1.28
Building against libxml2/libxslt in the following directory: /Users/mmoncrief/anaconda/envs/py27/lib

warning: no files found matching '*.txt' under directory 'src/lxml/tests'
Downloading/unpacking update
Could not find any downloads that satisfy the requirement update
No distributions at all found for update
Storing complete log in /Users/mmoncrief/.pip/pip.log

尝试卸载 lxml 并使用 pip 重新安装,但出现 clang 错误和段错误。这是 pip.log 的部分:

    /Users/mmoncrief/anaconda/envs/py27/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'

warnings.warn(msg)

Building lxml version 3.2.3.

Building without Cython.

Using build configuration of libxslt 1.1.28

Building against libxml2/libxslt in the following directory: /Users/mmoncrief/anaconda/envs/py27/lib

running install

running build

running build_py

copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.5-x86_64-2.7/lxml/includes

running build_ext

building 'lxml.etree' extension

/usr/bin/clang -fno-strict-aliasing -I/Users/mmoncrief/anaconda/envs/py27/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/mmoncrief/anaconda/envs/py27/include -I/Users/mmoncrief/anaconda/envs/py27/include/libxml2 -I/private/var/folders/l2/zvz4t5rs7pb3n1bc4_bdz6n4cbzgwl/T/pip-build-mmoncrief/lxml/src/lxml/includes -I/Users/mmoncrief/anaconda/envs/py27/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.5-x86_64-2.7/src/lxml/lxml.etree.o -flat_namespace

clang: warning: argument unused during compilation: '-flat_namespace'

src/lxml/lxml.etree.c:136455:17: warning: enumeration value '__pyx_e_4lxml_5etree_PARSER_DATA_INVALID' not handled in switch [-Wswitch]

switch (__pyx_v_doc_ref->_type) {

^

src/lxml/lxml.etree.c:140541:72: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types]

__pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_self->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L9;}

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/lxml/lxml.etree.c:138476:138: note: passing argument to parameter '__pyx_v_self' here

static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) {

^

src/lxml/lxml.etree.c:141947:70: warning: incompatible pointer types passing 'struct __pyx_obj_4lxml_5etree__BaseContext *' to parameter of type 'struct __pyx_obj_4lxml_5etree__XSLTContext *' [-Wincompatible-pointer-types]

__pyx_t_1 = ((PyObject *)__pyx_f_4lxml_5etree_12_XSLTContext__copy(((struct __pyx_obj_4lxml_5etree__BaseContext *)__pyx_v_stylesheet->_context))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/lxml/lxml.etree.c:138476:138: note: passing argument to parameter '__pyx_v_self' here

static struct __pyx_obj_4lxml_5etree__BaseContext *__pyx_f_4lxml_5etree_12_XSLTContext__copy(struct __pyx_obj_4lxml_5etree__XSLTContext *__pyx_v_self) {

^

src/lxml/lxml.etree.c:160878:19: warning: expression result unused [-Wunused-value]

PyObject_INIT(o, t);

^

/Users/mmoncrief/anaconda/envs/py27/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT'

( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

^

src/lxml/lxml.etree.c:162691:19: warning: expression result unused [-Wunused-value]

PyObject_INIT(o, t);

^

/Users/mmoncrief/anaconda/envs/py27/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT'

( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

^

src/lxml/lxml.etree.c:168247:19: warning: expression result unused [-Wunused-value]

PyObject_INIT(o, t);

^

/Users/mmoncrief/anaconda/envs/py27/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT'

( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

^

src/lxml/lxml.etree.c:170913:19: warning: expression result unused [-Wunused-value]

PyObject_INIT(o, t);

^

/Users/mmoncrief/anaconda/envs/py27/include/python2.7/objimpl.h:164:69: note: expanded from macro 'PyObject_INIT'

( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )

^

src/lxml/lxml.etree.c:12774:13: warning: function '__pyx_f_4lxml_5etree_displayNode' is not needed and will not be emitted [-Wunneeded-internal-declaration]

static void __pyx_f_4lxml_5etree_displayNode(xmlNode *__pyx_v_c_node, PyObject *__pyx_v_indent) {

^

8 warnings generated.

/usr/bin/clang -bundle -undefined dynamic_lookup -L/Users/mmoncrief/anaconda/envs/py27/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/src/lxml/lxml.etree.o -L/Users/mmoncrief/anaconda/envs/py27/lib -lxslt -lexslt -lxml2 -lz -lm -o build/lib.macosx-10.5-x86_64-2.7/lxml/etree.so

clang: error: unable to execute command: Segmentation fault: 11

clang: error: linker command failed due to signal (use -v to see invocation)

error: command '/usr/bin/clang' failed with exit status 254

----------------------------------------

Command /Users/mmoncrief/anaconda/envs/py27/bin/python -c "import setuptools;__file__='/private/var/folders/l2/zvz4t5rs7pb3n1bc4_bdz6n4cbzgwl/T/pip-build-mmoncrief/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/l2/zvz4t5rs7pb3n1bc4_bdz6n4cbzgwl/T/pip-vTKUXu-record/install-record.txt --single-version-externally-managed failed with error code 1 in /private/var/folders/l2/zvz4t5rs7pb3n1bc4_bdz6n4cbzgwl/T/pip-build-mmoncrief/lxml

Exception information:
Traceback (most recent call last):
File "/Users/mmoncrief/anaconda/envs/py27/lib/python2.7/site-packages/pip/basecommand.py", line 139, in main
status = self.run(options, args)
File "/Users/mmoncrief/anaconda/envs/py27/lib/python2.7/site-packages/pip/commands/install.py", line 271, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/Users/mmoncrief/anaconda/envs/py27/lib/python2.7/site-packages/pip/req.py", line 1185, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/Users/mmoncrief/anaconda/envs/py27/lib/python2.7/site-packages/pip/req.py", line 592, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "/Users/mmoncrief/anaconda/envs/py27/lib/python2.7/site-packages/pip/util.py", line 662, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command /Users/mmoncrief/anaconda/envs/py27/bin/python -c "import setuptools;__file__='/private/var/folders/l2/zvz4t5rs7pb3n1bc4_bdz6n4cbzgwl/T/pip-build-mmoncrief/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/l2/zvz4t5rs7pb3n1bc4_bdz6n4cbzgwl/T/pip-vTKUXu-record/install-record.txt --single-version-externally-managed failed with error code 1 in /private/var/folders/l2/zvz4t5rs7pb3n1bc4_bdz6n4cbzgwl/T/pip-build-mmoncrief/lxml

非常感谢任何帮助!

最佳答案

注意错误信息:

ImportError: cssselect seems not to be installed. See http://packages.python.org/cssselect/


cssselect 已被移动成为一个单独的包。尝试安装它

pip install cssselect

关于python - pip lxml 安装段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18048662/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com