CV2: Import Error in Python OpenCV - python

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.

Related

ModuleNotFoundError: No module named 'feedparser'

I have Python 3.11 and I have done everything expect Anaconda thing in this video below to try and fix this issue.
https://www.youtube.com/watch?v=RvbUqf3Tb1s&t=181s&ab_channel=TechWithTim
Here is the error:
C:\Python311\python.exe
C:\Users\16789\PycharmProjects\cyberNewsfeed\main.py Traceback (most
recent call last): File
"C:\Users\16789\PycharmProjects\cyberNewsfeed\main.py", line 1, in
import feedparser ModuleNotFoundError: No module named 'feedparser'
Attached is a screenshot of my interpeter and structue.
Tried everything in the linked video besides anaconda and i was expecting it to run. I restarted my computer as well.
You have to install the missing package. Try this in a shell inside your python environment.
pip install feedparser

Import CV2: DLL load failed: The specified module could not be found while successful pip installation

I was working with Python 3.7 and OpenCV 4.2 in Pycharm IDE (Windows10). The system environment variables were changed by one of my co-workers by accident (we don't know what happened exactly). Then I found that my code did not work with this error!:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
Then I used this command:
pip uninstall opencv-python
pip uninstall opencv-contrib-python
pip install opencv-python
All of them executed successfully, but when I write import cv2 the above error is appeared. By the way, the system knows command Python, it shows the right path to the python.exe. Moreover, commands like import numpy works correctly! How can I fix this problem?
I found the answer! There was an extra cv2.py file in site-packages/cv2 path. So, I removed it and the code worked

I am unable to import psycopg2 from Jupyter notebook or Jupyter Lab on Mac. I have a clean install of Catalina

A similar report was posted, but the suggested solutions do not work.
---- from Jupyter ----
Import psycopg2
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-7d2da0a5d979> in <module>
----> 1 import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
If I run python3 from Mac terminal and then import psycopg2 that works.
If I run python3 from Jupyterlab terminal this does not work. I get the following error after running import pyscopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so, 2): Library not loaded: #rpath/libssl.1.1.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so
Reason: image not found
echo $PATH from Mac terminal is
/Users/greg/opt/miniconda3/bin:/Users/greg/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
echo $PATH from Jupyterlab terminal is
/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/greg/opt/miniconda3/bin:/Users/greg/opt/anaconda3/condabin
These look the same, just in a different order.
I have tried pip install psycopg2 both with and without the binary option.Either way, it says already satisfied.
I have tried
conda install -c anaconda psycopg2
Also tried installing postgresql both from the postgresql.org, and brew install psycopg2. Both worked, but no luck with Jupyterlab.
try installing the package using: pip install psycopg2-binary. This should work.
For more information, visit: https://www.psycopg.org/docs/install.html

python3 openCV install error: Symbol not found: _clock_gettime

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.

no module named cv2 on exporting anaconda path

I have ubuntu 14.04 in which I installed OpenCV3 it works fine
then I installed anaconda(python). To make it work it said that I have to edit ~/.bashrc and export the anaconda path to it.
I changed to python 2.7.8 and it gives an error: no module named cv2 error.. and if I comment that line in .bashrc then python gets changed to 2.7.6 and the error disappears. What should I do ?
This is the error when I include the line in bashrc
Traceback (most recent call last):
File "test.py", line 7, in <module>
import cv2
ImportError: /home/aman/anaconda/bin/../lib/libm.so.6: version `GLIBC_2.15' `not found (required by /usr/lib/x86_64-linux-gnu/libxvidcore.so.4)
Try running conda remove system. This will remove the libm.so.6 file from Anaconda. See https://github.com/ContinuumIO/anaconda-issues/issues/182

Categories