首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Mutalyzer py.test在python魔术错误中失败

Mutalyzer py.test在python魔术错误中失败
EN

Stack Overflow用户
提问于 2015-12-31 04:43:32
回答 2查看 406关注 0票数 0

我正试图按照变性剂2.0.14指令使用Anaconda Python 2.7Centos 6.7上安装这些

我的安装很好,但是当我尝试运行py.test套件时,会遇到一系列的失败。

我怀疑操作系统的libmagic版本和python2.7包python-magic之间存在版本冲突。

如果有人能解释这里发生了什么,或者更好地建议解决这个问题,我会非常感兴趣的。

我的魔术装备:

代码语言:javascript
运行
复制
$ rpm -qa | grep 'file-'
file-libs-5.04-21.el6.x86_64
file-5.04-21.el6.x86_64
file-devel-5.04-21.el6.x86_64

相应的Python包:

代码语言:javascript
运行
复制
$ source activate  py27
discarding /opt/anaconda2/bin from PATH
prepending /opt/anaconda2/envs/py27/bin to PATH
(py27) $ pip list | grep magic 
Magic-file-extensions (0.2, /home/chris.guest/temp/mutalyzer/src/magic-file-extensions)
python-magic (0.4.10)

py.test的开头如下:

代码语言:javascript
运行
复制
# py.test
======================================================= test session starts =======================================================
platform linux2 -- Python 2.7.11, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: /home/chris.guest/temp/mutalyzer, inifile: 
collected 610 items / 3 errors 

tests/test_backtranslator.py ......
tests/test_base.py .
tests/test_crossmap.py .......................
tests/test_grammar.py ........................................................................................
tests/test_mapping.py ..............................
tests/test_migrations.py .
tests/test_mutator.py ................................................................................................................................................................
tests/test_ncbi.py ............................................................................................................
tests/test_parsers_genbank.py ..........

最后犯了很多错误。许多测试由于undefined symbol: magic_list而失败

代码语言:javascript
运行
复制
_________________________________________ ERROR at setup of test_batch_unicode[sqlite://] _________________________________________

    @pytest.fixture
    def website():
>       return create_app().test_client()

tests/test_website.py:29: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
mutalyzer/website/__init__.py:35: in create_app
    from mutalyzer.website.views import website
mutalyzer/website/views.py:26: in <module>
    from mutalyzer import (announce, backtranslator, File, Retriever, Scheduler,
mutalyzer/File.py:23: in <module>
    import magic           # open(), MAGIC_MIME, MAGIC_NONE
src/magic-file-extensions/magic.py:94: in <module>
    _list = _libraries['magic'].magic_list
/opt/anaconda2/envs/py27/lib/python2.7/ctypes/__init__.py:378: in __getattr__
    func = self.__getitem__(name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <CDLL 'libmagic.so.1', handle 160cc50 at 7f23b97340d0>, name_or_ordinal = 'magic_list'

    def __getitem__(self, name_or_ordinal):
>       func = self._FuncPtr((name_or_ordinal, self))
E       AttributeError: /usr/lib64/libmagic.so.1: undefined symbol: magic_list

/opt/anaconda2/envs/py27/lib/python2.7/ctypes/__init__.py:383: AttributeError
______________________________________ ERROR at setup of test_batch_unicode_email[sqlite://] ______________________________________

    @pytest.fixture
    def website():
>       return create_app().test_client()

tests/test_website.py:29: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
mutalyzer/website/__init__.py:35: in create_app
    from mutalyzer.website.views import website
mutalyzer/website/views.py:26: in <module>
    from mutalyzer import (announce, backtranslator, File, Retriever, Scheduler,
mutalyzer/File.py:23: in <module>
    import magic           # open(), MAGIC_MIME, MAGIC_NONE
src/magic-file-extensions/magic.py:94: in <module>
    _list = _libraries['magic'].magic_list
/opt/anaconda2/envs/py27/lib/python2.7/ctypes/__init__.py:378: in __getattr__
    func = self.__getitem__(name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <CDLL 'libmagic.so.1', handle 160cc50 at 7f23b984ef50>, name_or_ordinal = 'magic_list'

    def __getitem__(self, name_or_ordinal):
>       func = self._FuncPtr((name_or_ordinal, self))
E       AttributeError: /usr/lib64/libmagic.so.1: undefined symbol: magic_list

/opt/anaconda2/envs/py27/lib/python2.7/ctypes/__init__.py:383: AttributeError
============================================== 548 passed, 65 error in 41.42 seconds ==============================================
(py27)[root@localhost mutalyzer]# 
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-01-11 04:39:29

与CentOS6.7一起打包的magiclib版本缺少magic_list函数。

我能够将这个补丁安装到src/magic-file-extensions/magic.py上,这样py.test就可以正常运行了。

代码语言:javascript
运行
复制
$ diff -u src/magic-file-extensions/magic.old.py src/magic-file-extensions/magic.py
--- src/magic-file-extensions/magic.old.py  2015-12-31 14:04:50.769635453 +1100
+++ src/magic-file-extensions/magic.py  2016-01-11 15:17:49.987270845 +1100
@@ -91,9 +91,13 @@
 _check.restype = c_int
 _check.argtypes = [magic_t, c_char_p]

-_list = _libraries['magic'].magic_list
-_list.restype = c_int
-_list.argtypes = [magic_t, c_char_p]
+try:
+    _list = _libraries['magic'].magic_list
+    _list.restype = c_int
+    _list.argtypes = [magic_t, c_char_p]
+except AttributeError, e:
+    _list = None
+    

 _errno = _libraries['magic'].magic_errno
 _errno.restype = c_int

虽然直接的AttributeError是用这个补丁处理的,但是如果调用src/magic-file-extensions/magic.py中的Magic.list方法,它仍然会失败。这不是一个直接的问题,因为它似乎不是在mutalyzer代码库中调用的。

票数 0
EN

Stack Overflow用户

发布于 2015-12-31 14:14:55

我们有一个早期的报告说,一个用户试图在CentOS 6上安装Mutalyzer,而他们也遇到了Lib魔术的麻烦。我不认为这是解决了,除了他们切换到CentOS 7。

不幸的是,我们的资源非常有限,Debian是我们自己使用的唯一操作系统,这是我们能够实际支持的全部。当然,我们很乐意接受补丁或文档更新:)

谢谢你使用Mutalyzer!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34541129

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档