2013-08-04 2 views
1

Запуск Python 2.7.5 и OSX 10.8. Также работает Python в виртуальном env, созданный с помощью менеджера пакетов Anaconda. У меня XCode 4.6.3 с установленными инструментами командной строки.pip lxml install segmentation fault

Мессинг вокруг с 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.

Я пробовал обновлять lxml, используя pip install lxml --update. Это дает ответ:

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 и переустановка с ПУМАМИ, и я получаю ошибку лязга и сегмы неисправности. Вот раздел fro 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 

Любая помощь очень ценится!

+0

В OSX у меня было t рубль установка lxml из pip. easy_install, похоже, работает лучше, но лучше всего просто загрузить код напрямую и запустить python setup.py install – synthesizerpatel

ответ

2

Примечание сообщение об ошибке:

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


cssselect был перемещен, чтобы стать отдельным пакетом. Попробуйте установить его с

pip install cssselect 
+0

, который работал, хотя я также обновил anaconda -распределенный lxml, поэтому я не уверен, что это трюк. Спасибо, много. – user2651369

+0

Ошибка clang все еще присутствует. Например, попытка установки Scrapy, которая требует lxml, приводит к той же ошибке clang. – user2651369