我在运行名为 nsilk 的质谱代码时遇到了问题,该代码具有 NumPy、SciPy 和 BioPython 作为依赖项。由于我在我的 Mac (Mountain Lion) 上运行其他基于 Python 的项目,我想使用 virtualenv/pip 分离出虚拟环境以安装 nsilk。
运行 nsilk 命令后(我使用 'which' 检查它指向虚拟环境中的版本,而不是系统范围的安装),我收到以下回溯:
Traceback (most recent call last):
File "/usr/local/bin/nsilk", line 32, in <module>
import xllib
File "/Library/Python/2.7/site-packages/xllib/__init__.py", line 30, in <module>
import MSMS
File "/Library/Python/2.7/site-packages/xllib/MSMS.py", line 32, in <module>
import scipy.stats as ss
ImportError: No module named scipy.stats
进入(virtualenv)Python shell 后,如果我尝试直接导入 scipy.stats,我不会收到任何投诉:
>>> import scipy.stats as ss
>>>
但是,当我运行 scipy.test() 时,我收到大量错误:
>>> import scipy
>>> scipy.test()
以下是前三个:
======================================================================
ERROR: test_logm_consistency (test_matfuncs.TestExpM)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Mike/venvs/nsilk/lib/python2.7/site-packages/scipy/sparse/linalg/tests/test_matfuncs.py", line 55, in test_logm_consistency
assert_array_almost_equal(expm(logm(a)), a)
File "/Users/Mike/venvs/nsilk/lib/python2.7/site-packages/scipy/linalg/matfuncs.py", line 387, in logm
errest = norm(expm(F)-A,1) / norm(A,1)
File "/Users/Mike/venvs/nsilk/lib/python2.7/site-packages/scipy/linalg/matfuncs.py", line 55, in expm
return scipy.sparse.linalg.expm(A)
File "/Users/Mike/venvs/nsilk/lib/python2.7/site-packages/scipy/sparse/linalg/matfuncs.py", line 85, in expm
A_L1 = norm(A,1)
File "/Users/Mike/venvs/nsilk/lib/python2.7/site-packages/scipy/linalg/misc.py", line 116, in norm
a = np.asarray_chkfinite(a)
File "/Users/Mike/venvs/nsilk/lib/python2.7/site-packages/numpy/lib/function_base.py", line 590, in asarray_chkfinite
"array must not contain infs or NaNs")
ValueError: array must not contain infs or NaNs
======================================================================
FAIL: test_asum (test_blas.TestFBLAS1Simple)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Mike/venvs/nsilk/lib/python2.7/site-packages/scipy/lib/blas/tests/test_blas.py", line 62, in test_asum
assert_almost_equal(f([3,-4,5]),12)
File "/Users/Mike/venvs/nsilk/lib/python2.7/site-packages/numpy/testing/utils.py", line 468, in assert_almost_equal
raise AssertionError(msg)
AssertionError:
Arrays are not almost equal to 7 decimals
ACTUAL: 0.0
DESIRED: 12
======================================================================
FAIL: test_dot (test_blas.TestFBLAS1Simple)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Mike/venvs/nsilk/lib/python2.7/site-packages/scipy/lib/blas/tests/test_blas.py", line 71, in test_dot
assert_almost_equal(f([3,-4,5],[2,5,1]),-9)
File "/Users/Mike/venvs/nsilk/lib/python2.7/site-packages/numpy/testing/utils.py", line 468, in assert_almost_equal
raise AssertionError(msg)
AssertionError:
Arrays are not almost equal to 7 decimals
ACTUAL: 0.0
DESIRED: -9
在安装 XCode 4.6.3 后,我使用 GCC 4.8.0 20120603(实验性)安装了 NumPy、SciPy 和 BioPython。我最初在安装 SciPy 时遇到了麻烦,因为它缺少一个名为 LibFFTPack(或类似的)的库。
谷歌搜索错误导致需要为 XCode 安装 Fortran 编译器。在执行 pip 时“修复”了 SciPy 编译时的那些回溯,但导致了上述问题!我认为有一些编译错误导致 SciPy 安装错误。这里可能存在混合编译器/二进制问题吗?
干杯,迈克。