3
我使用蟒蛇2.1.0與3.4.1蟒和剛剛建成的OpenCV 3.0.0-α在Mac OSX上的優勝美地使用下面的命令:OpenCV的3.0.0阿爾法與Python 3未能導入CV2
cmake -D CMAKE_BUILD_TYPE=RELEASE
-D BUILD_PERF_TESTS=OFF
-D BUILD_opencv_python3=ON
-D CMAKE_OSX_ARCHITECTURES=x86_64
-D CMAKE_INSTALL_PREFIX=/usr/local
-D PYTHON3_EXECUTABLE=${ANACONDA}/bin/python3
-D PYTHON3_LIBRARY=${ANACONDA}/lib/libpython3.4m.dylib
-D PYTHON3_INCLUDE_DIR=${ANACONDA}/include/python3.4m
-D PYTHON3_NUMPY_INCLUDE_DIRS=${ANACONDA}/lib/python3.4/site-packages/numpy/core/include
-D PYTHON3_PACKAGES_PATH=${ANACONDA}/lib/python3.4/site-packages ..
該建築似乎成功。建立opencv後,我得到了libopencv_*.dylib
文件。 但我無法導入CV2模塊:
Python 3.4.1 |Anaconda 2.1.0 (x86_64)| (default, Sep 10 2014, 17:24:09)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/scari/anaconda3/lib/python3.4/site-packages/cv2.so, 2): Library not loaded: libpython3.4m.dylib
Referenced from: /Users/scari/anaconda3/lib/python3.4/site-packages/cv2.so
Reason: image not found
>>>
下面是sys.path的輸出:
>>> sys.path
['', '/Users/scari/anaconda3/lib/python34.zip', '/Users/scari/anaconda3/lib/python3.4', '/Users/scari/anaconda3/lib/python3.4/plat-darwin', '/Users/scari/anaconda3/lib/python3.4/lib-dynload', '/Users/scari/anaconda3/lib/python3.4/site-packages', '/Users/scari/anaconda3/lib/python3.4/site-packages/Sphinx-1.2.3-py3.4.egg', '/Users/scari/anaconda3/lib/python3.4/site-packages/runipy-0.1.1-py3.4.egg', '/Users/scari/anaconda3/lib/python3.4/site-packages/setuptools-5.8-py3.4.egg']
我應該先檢查一下?
同樣的問題;成功構建但導入cv2失敗 – 2014-11-08 22:09:20