在Mac OS X 10.6.4系统中,我希望使用vigra库。我已经使用Macports安装了所有依赖项。一切正常,我也安装了vigra。但当我尝试导入vigra时,出现“Segmentation fault(段错误)”。有人知道如何解决这个问题吗?
以下是Mac OS X错误报告:
Process: Python [784] Path:
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
Identifier: Python Version:
??? (???) Code Type: X86-64
(Native) Parent Process: bash [779]
Date/Time: 2010-10-02
14:21:08.522 +0200 OS Version:
Mac OS X 10.6.4 (10F569) Report
Version: 6
Interval Since Last Report:
3444718 sec Crashes Since Last Report:
91 Per-App Crashes Since Last Report:
12 Anonymous UUID:
D1732CEB-3906-4947-832C-99C1C260905E
Exception Type: EXC_BAD_ACCESS
(SIGSEGV) Exception Codes:
KERN_INVALID_ADDRESS at
0x0000000000000000 Crashed Thread: 0
Dispatch queue: com.apple.main-thread
Thread 0 Crashed: Dispatch queue:
com.apple.main-thread 0 ???
000000000000000000 0 + 0 1
org.python.python
0x00000001010977f2 PyImport_Import +
139 2 org.python.python
0x000000010109799f
PyImport_ImportModule + 40 3
vigranumpycore.so
0x0000000100557b33
init_module_vigranumpycore() + 19 4
libboost_python-mt.dylib
0x000000010071f511
boost::python::handle_exception_impl(boost::function0)
+ 273 5 libboost_python-mt.dylib 0x0000000100720676 bool
boost::python::handle_exception(void (*)()) + 54 6
libboost_python-mt.dylib
0x000000010072041b
boost::python::detail::init_module(char
const*, void (*)()) + 91 7
org.python.python
0x00000001000d3911
_PyImport_LoadDynamicModule + 177 8 org.python.python
0x00000001000d1bcf import_submodule +
383 9 org.python.python
0x00000001000d20ea load_next + 234 10
org.python.python
0x00000001000d23fb
PyImport_ImportModuleLevel + 363 11
org.python.python
0x00000001000af973 builtin_import
+ 131 12 org.python.python 0x000000010000b902 PyObject_Call + 98
13 org.python.python
0x00000001000b0bb7
PyEval_CallObjectWithKeywords + 87 14
org.python.python
0x00000001000b4e7e PyEval_EvalFrameEx
+ 12622 15 org.python.python 0x00000001000b9af5 PyEval_EvalCodeEx
+ 2197 16 org.python.python 0x00000001000b9c16 PyEval_EvalCode +
54 17 org.python.python
0x00000001000ceac0
PyImport_ExecCodeModuleEx + 208 18
org.python.python
0x00000001000cfd22 load_source_module
+ 722 19 org.python.python 0x00000001000d12df load_package + 463
20 org.python.python
0x00000001000d1bcf import_submodule +
383 21 org.python.python
0x00000001000d20ea load_next + 234 22
org.python.python
0x00000001000d23fb
PyImport_ImportModuleLevel + 363 23
org.python.python
0x00000001000af973 builtin_import
+ 131 24 org.python.python 0x000000010000b902 PyObject_Call + 98
25 org.python.python
0x00000001000b0bb7
PyEval_CallObjectWithKeywords + 87 26
org.python.python
0x00000001000b4e7e PyEval_EvalFrameEx
+ 12622 27 org.python.python 0x00000001000b9af5 PyEval_EvalCodeEx
+ 2197 28 org.python.python 0x00000001000b9c16 PyEval_EvalCode +
54 29 org.python.python
0x00000001000de50c
PyRun_InteractiveOneFlags + 380 30
解决方案
- 使用
brew
安装Boost库
brew install boost
- 使用
pip
安装numpy库
pip install numpy
- 使用
pip
安装vigra库
pip install vigra
- 在代码中导入vigra模块
import vigra
- 重新运行代码
import vigra
image = vigra.readImage('image.png')
代码例子
import vigra
# Read an image
image = vigra.readImage('image.png')
# Apply a Gaussian filter to the image
smoothed_image = vigra.gaussianSmoothing(image, sigma=1.0)
# Display the original and smoothed images side-by-side
vigra.imshow(image, title='Original Image')
vigra.imshow(smoothed_image, title='Smoothed Image')