2015-12-31 63 views
0

我正嘗試在Centos 6.7上使用Anaconda Python 2.7按照these的說明安裝mutalyzer 2.0.14Mutalyzer py.test以python-magic錯誤失敗

我的安裝很好,但是當我嘗試運行py.test套件時,我遇到了一系列失敗。

我懷疑操作系統版本libmagic和python2.7包python-magic之間存在版本衝突。

如果有人能夠解釋這裏發生了什麼或者更好地解決這個問題,我會非常感興趣。

我libmagic安裝:

$ 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包:

$ 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是這樣開始的:

# 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失敗:

_________________________________________ 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)[[email protected] mutalyzer]# 

回答

0

與Centos 6.7打包在一起的magiclib版本缺少magic_list函數。

我能夠使這個補丁src/magic-file-extensions/magic.py,使py.test運行沒有錯誤。

$ 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.pyMagic.list方法仍然會失敗,如果它被調用。這不是一個直接的問題,因爲它似乎不在mutalyzer代碼庫中調用。

+0

@MartijnVermaat如果您認爲它會有幫助,請隨時將此補丁添加到'mutalyzer'代碼庫。 – ChrisGuest

1

我們必須試圖在CentOS 6安裝Mutalyzer用戶的一個早期的報告,他們也遇到了與libmagic煩惱。我不認爲這個問題已經解決,除了他們改用CentOS 7.

不幸的是,我們的資源非常有限,Debian是我們自己使用的唯一的操作系統,這些都是我們切實可以支持的。當然,我們很樂意接受補丁或文檔更新:)

感謝您使用Mutalyzer!

+0

這不提供問題的答案。要批評或要求作者澄清,在他們的帖子下留下評論 - 你總是可以評論你自己的帖子,一旦你有足夠的[聲譽](http://stackoverflow.com/help/whats-reputation),你會能夠[評論任何帖子](http://stackoverflow.com/help/privileges/comment)。 - [來自評論](/ review/low-quality-posts/10739374) – grahamj42

+1

對不起,我試圖離開這作爲評論,但被禁止,因爲它需要一定的聲譽。另外,由於我是被引用軟件(Mutalyzer)的主要維護者,因此這是關於如何運行Mutalyzer的最具權威性的答案:升級到CentOS 7或在Debian上運行它。我相信爲@ChrisGuest所要求的問題提供* a *修正。如果問題是關於如何在CentOS 6上使用python-magic的更一般的話,我會同意我沒有答案。 –

+0

@MartijnVermaat感謝您對此作出迴應。我會將問題留待一段時間,看看是否有其他人對此有迴應。 如果一切都失敗了,我可能會得到一個Centos7盒子委託。 – ChrisGuest