I've successfully installed OpenCV, but when I try to import it in Python, I get the errors below.
In Python 2.7, I'm getting this
[imukunya#li165-244 site-packages]$ python
Python 2.7.5 (default, Oct 30 2018, 23:45:53)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import
In Python 3.6, I'm getting this error
[imukunya#li165-244 site-packages]$ python3.6
Python 3.6.5 (default, Apr 10 2018, 17:08:37)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define module export function (PyInit_cv2)
I've already tried installing NumPy using $~python3 -m pip install numpy -I
Please try to execute the below command. Then please verify whether your code is working.
python -m pip install opencv-contrib-python
Related
I am not able to launch git-cola on Ubuntu 20.04. As a troubleshooting exercise, I did this:
darnstein#EXTP346360104:Downloads$ python3
Python 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5.QtWidgets import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/lib/python3/dist-packages/PyQt5/QtWidgets.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZTI13QOpenGLWidget, version Qt_5
What should I do to resolve the undefined symbol?
I have packages python3-qt5 python3-pyqt5 installed already.
I'm currently working on a project with anaconda. I was able to install opencv-python with the regular pip3 install (not anacondas version). When I import cv2, its successful.
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
If I copy that package into my anaconda path, and run python with anaconda, import cv2 I get the following error:
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
Is there a way to get around this without using the Anacondas pip install? I don't have internet on the machine I'm working on. I've done this method with other packages and it has worked fine, not with opencv.
My system has python3 as the default for python command.
when I try to import flask on python command line I get this:
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named flask
>>>
but in python3 i get this:
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
>>>
How do i correct this?
It looks you are using two different packaging systems: pip and conda. For Python2, try pip2 install flask.
I'm on a Mac. Step 1:
sudo conda install -c conda-forge shogun
Step 2:
$ python
Python 2.7.12 |Anaconda custom (x86_64)| (default, Jul 2 2016, 17:43:17)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import shogun
>>> from shogun import RealFeatures, PolyKernel, CSVFile
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name RealFeatures
I also tried on Fedora using the RPMs. After verifying that the C++ interface works (gcc shogun.cpp -I/usr/include/shogun/base -lshogun -L/usr/lib64/libshogun.*) I followed the instructions here and set PYTHONPATH=/usr/lib64/python2.7/site-packages/modshogun.py
And then:
$ python
Python 2.7.13 (default, May 10 2017, 20:04:36)
[GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import shogun
>>> from shogun import RealFeatures, PolyKernel, CSVFile
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name RealFeatures
The problem here is probably that shogun's docs are currently for the in-development version 6.1, but the conda package is for the latest actual release 6.0. In 6.0, you need to do from modshogun import RealFeatures; the shogun package is the old interface, and the modern "modular" one is modshogun. This will be renamed to just shogun in the upcoming 6.1 release.
I installed the latest version of lxml.etree compatible with Python 3.4. However when I try importing the package, I hit the following error:
> python
Python 3.4.1 (default, Nov 12 2014, 13:34:29)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /users/vinapai/nxapi/pyats/lib/python3.4/site-packages/lxml/etree.cpython-34m.so: undefined symbol: xmlMemDisplayLast
>>>
I tried using both pip install and easy_install and tried different packages of lxml but consistently hit this error. Any help would be greatly appreciated.