Error in loading OpenCV from Python on OS X Marericks - c++

I've correctly build OpenCV in OS X and I can use it with C++,
however, when I try to load the cv2 module from Python, I get this error:
import cv2
Traceback (most recent call last):
File "", line 1, in
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/cv2.so, 2): Symbol not found: _ZN2cv11FileStorageC1ERKSsiS2
Referenced from: /usr/local/lib/python2.7/site-packages/cv2.so
Expected in: lib/libopencv_core.2.4.dylib
in /usr/local/lib/python2.7/site-packages/cv2.so
I have the same issue both with python and opencv installed from macports and when compiling OpenCV by my self. I have tried to use Python 2.7.5 and 2.7.6 and opencv 2.4.5 and 2.4.6.1

Related

ImportError: No module named cv2 on macox

I have used homebrew to install OpenCV, but I cannot use it, when I import OpenCV in Python, I meet this error:
ImportError: No module named cv2; op
system:macos10.12.6
opencv 3.3.0_2
python 2.7.13

How to Display a Geotiff image using Python

I am new to Python2.7 and have tried installing rasterio,using wheel file,but still the following error comes:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import rasterio
File "D:\Python\lib\site-packages\rasterio\__init__.py", line 23, in <module>
from rasterio._base import (
ImportError: DLL load failed: The specified module could not be found.
I accidentally deleted my old comment,here is the code :
from osgeo import gdal
import matplotlib.pyplot as plt
ds = gdal.Open('filename.tif').ReadAsArray()
im = plt.imshow(ds)
This will work.
I am not familiar with Rasterio, but if you are looking for some library to do image analysis or just display a geotiff image, you could probably take a look at opencv python library.
Link : OpenCV3
TuiView is an open source PyQt-based lightweight Raster GI. Its available on Windows, Mac and Linux: http://tuiview.org

ImportError: Numpy OpenBLAS flavour is needed for this scipy build

I use python 2.7 on PyCharm and I try to make a surface from a file points and i read that the way from do this is through libraries matplotlib, mpl_toolkits. But when i run the code that i copy from example's web i have this error:
C:\Python27\python.exe C:/Users/rublloal/PycharmProjects/untitled3/matplotlib1.py
Traceback (most recent call last):
File "C:/Users/rublloal/PycharmProjects/untitled3/matplotlib1.py", line 10, in
from scipy.misc import imread # Cargo imread de scipy.misc
File "C:\Python27\lib\site-packages\scipy__init__.py", line 122, in
raise ImportError("Numpy OpenBLAS flavour is needed for this scipy build.")
ImportError: Numpy OpenBLAS flavour is needed for this scipy build.
thanks
I use python 2.7 on PyCharm and I downgrade the scipy 0.18 to 0.16 and I had the same problem as you, but I reinstall numpy - (numpy-1.10.0b1-cp27-none-win32.whl) by pip.
You can find the wheel here: https://pypi.anaconda.org/carlkl/simple/numpy/
and problem disappear.
Maybe I answered to late, but I hope it will help someone else :)

Upgrade to Python 2.7.10: Target WSGI script cannot be loaded as Python module

When I upgrade Python from 2.7.9 to 2.7.10 with anaconda, I get the following error in my apache2 log and my websites don't work any more.
mod_wsgi (pid=608): Target WSGI script '/www/wsgi_scripts/django_myproject.wsgi' cannot be loaded as Python module.
Exception occurred processing WSGI script '/www/wsgi_scripts/django_myproject.wsgi'.
Traceback (most recent call last):
File "/www/wsgi_scripts/django_myproject.wsgi", line 8, in <module>
import django.core.handlers.wsgi
File "/Users/xnx/anaconda/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 6, in <module>
from io import BytesIO
File "/Users/xnx/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/xnx/anaconda/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
Referenced from: /Users/xnx/anaconda/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
I expect this is some kind of mismatch in package library versions, but does anyone know which one?
Double check your PYTHONPATH if it's correct (you don't override it anywhere in your startup files).
Otherwise you may consider downgrading your Python from 2.7.10 to 2.7.9.
For example (as suggested in here):
conda install python=2.7.9
or when using Homebrew try:
brew switch python 2.7.9
as it could be some particular problem with 2.7.10.
Alternatively use Python 3.x instead.
My suspicion is that this is a problem with Anaconda as I've just hit the same problem. I've reported an issue here: https://github.com/conda/conda/issues/1367
update:
The conda guys have now released a fixed virtualenv package that no longer has this problem.

PortAudio Symbol not found: _PaMacCore_SetupChannelMap on Mountain Lion

I tried installing pyaudio (tried both with pip and easy_install) by running the following
brew install portaudio
[pip or easy_install command]
sudo pip install pyaudio
sudo easy_install pyaudio
However when I run import _portaudio in the python inerpreter it gives me this
>>> import _portaudio
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Python/2.7/site-packages/PyAudio-0.2.7-py2.7-macosx-10.8-intel.egg/_portaudio.so, 2): Symbol not found: _PaMacCore_SetupChannelMap
Referenced from: /Library/Python/2.7/site-packages/PyAudio-0.2.7-py2.7-macosx-10.8-intel.egg/_portaudio.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/PyAudio-0.2.7-py2.7-macosx-10.8-intel.egg/_portaudio.so
Is your path setup right to find the port audio dll file? Does the dependency come already: pyPortAudio/fastaudio or does it require a separate install?
BTW: This might or might not meet your requirements but have you considered using scipy.io.wavfile?
import scipy.io.wavfile
fs1, y1 = scipy.io.wavfile.read(filename)
I moved from using apple's python to using macports python27 and then installed pyaudio with that.