python3 openCV install error: Symbol not found: _clock_gettime - python

Can anyone help me fixing an error when importing opencv in python3?
when I import cv2 in python3, I get something like
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/cv2/__init__.py", line 4, in <module>
from .cv2 import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/cv2/cv2.cpython-36m-darwin.so, 2):
Symbol not found: _clock_gettime
Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/cv2/.dylibs/libavutil.55.78.100.dylib
(which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/cv2/.dylibs/libavutil.55.78.100.dylib
Also, I'm using python version 3.6.3

If you don't want to upgrade your OS, you can install an earlier version of opencv:
pip install opencv-python==3.3.0.10

clock_gettime() was added in macOS 10.12. It says so in the error message.
From what I understand it may be possible to build against an earlier Xcode SDK, but the easiest is probably to upgrade to Mac's latest OS.

Related

IfxPy module import error after succesfull installation

I am experiencing an issue with IfxPy installation.
The operating system is windows 64 bit and the 64-bit version of Python 3.7.4 is runned.
After pip installation of the wheel file IfxPy-3.0.3-cp37-cp37m-win_amd64.whl from - https://pypi.org/project/IfxPy/#files the pip list command or help(modules) command from interpreteur shows that the module is installed:
>>> help("modules")
Please wait a moment while I gather a list of all available modules... IfxPy [...other modules...]
I try to find the location of the module, and it is
>>> imp.find_module('IfxPy') (<_io.BufferedReader name='C:\\Python\\lib\\site-packages\\IfxPy.pyd'>,
'C:\\Python\\lib\\site-packages\\IfxPy.pyd', ('.pyd', 'rb', 3))
The PATH environmental variable contains the abovementioned path.
However, when I try to import the module from IDLE interpreteur I get the error:
>>> import IfxPy
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import IfxPy ImportError: DLL load failed: The specified module could not be found.
What could be the potential source of the error and how can it be solved? Thanks for help.

CV2: Import Error in Python OpenCV

I have Anaconda installed in my system and I recently installed OpenCV 3.0.0 using the instructions given on this page. But when I open python and type import cv2, it throws me the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/ashutosh/anaconda2/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/local/lib/python2.7/site-packages/cv2.so)
I dont't know why am I getting this error. I also put the PYTHONPATH in the bashrc file, sourced it but nothing happened.
sudo apt-get install libgcc
This dependency caused the error.

Python ImportError with MySQLdb on Mac OS X (El Capitan)

I have installed MySQLdb on El Capitan using:
brew install mysql
pip install MySQL-python
When I try python -c "import MySQLdb" I get the following error:
File "<string>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(./_mysql.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Users/<user>/anaconda/lib/python2.7/site-packages/_mysql.so
Reason: no suitable image found. Did find:
/usr/local/bin/mysql/lib/libssl.1.0.0.dylib: stat() failed with errno=20
Found some related posts but still did not figure out how to fix this. Any help is much appreciated.
EDIT:
If I decide to revert step 1 (brew uninstall mysql) because SQLite (sqlite3) comes pre-installed with El Capitan, I get the following error message:
File "<string>", line 1, in <module>
File "/Users/<user>/anaconda/lib/python2.7/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Users/<user>/anaconda/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib
Referenced from: /Users/<user>/anaconda/lib/python2.7/site-packages/_mysql.so
Reason: image not found
What am I missing? Are the two error messages related?
I got an error like this after, I assume, homebrew updated mysql. By running pip uninstall mysqlclient && pip install mysqlclient I got things working again without having to set DYLD_LIBRARY_PATH.

Python Basemap/Matplotlib Install

I am trying to install the base map for use with matplotlib python v2.7 running on Mac OSX Mavericks. I have all the latest versions of all modules (matplotlib, etc) running using anaconda, but keep getting the following error:
Traceback (most recent call last):
File "simpletest.py", line 1, in <module>
from mpl_toolkits.basemap import Basemap
File "/Users/felishalawrence/anaconda/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py", line 37, in <module>
import _geoslib.so
ImportError: dlopen(/Users/felishalawrence/anaconda/lib/python2.7/site-packages/_geoslib.so, 2): Library not loaded: libgeos_c.1.dylib
Referenced from: /Users/felishalawrence/anaconda/lib/python2.7/site-packages/_geoslib.so
Reason: no suitable image found. Did find:
/usr/local/bin/gcc-4.9/libgeos_c.1.dylib: stat() failed with errno=20
Can someone please give me an idea of what is wrong? Thanks!
Try installing the following packages with Homebrew:
brew install numpy
brew install proj
brew install geos
export GEOS_DIR="/usr/local/Cellar/geos/3.10.3/"

"Expected in: flat namespace" error when importing networkx in python

I'm getting a strange error which I can't make sense of.
On Python 2.7, I installed the py27-networkx package using MacPorts. When I try to import networkx as nx, I get the error below. The only line in my network.py file is the import one.
Any ideas on how to debug this to work out what's happening?
Traceback (most recent call last):
File "network.py", line 1, in <module>
import networkx
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/networkx/__init__.py", line 43, in <module>
from networkx import release
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/networkx/release.py", line 45, in <module>
import subprocess
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 427, in <module>
import select
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/select.so, 2): Symbol not found: __PyInt_AsInt
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/select.so
Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/select.so
Update
Ran a few pieces to help diagnose. Hope it helps someone provide some insight and a solution to this for me.
which python gives me /opt/local/bin/python (I have the standard Mac OS X python, but am using a MacPorts installed version of python2.7)
Running import networkx from the python prompt produces no errors
Anything else I can try?
I also had this error and i fixed by upgrading python27 with macports.
Update macports to the latest version:
sudo port selfupdate
List outdated packages (python27 was outdated for me, when I was getting the import error):
sudo port outdated
Update the outdated packages:
sudo port upgrade outdated

Categories