DLL load failed : in installing opencv2? - python

Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 15:51:26) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.
I am trying to install open cv on python but this message shows up.
should I download opencv of 32 bit is this the case?

The problem is with incompatible lib.numpy is (mostly) compatible with 32bit.
So install
Python (32bit)
Numpy
OpenCV(32 bit)
Python 2.7 is only compatible with OpenCV2
Doesn't matter if you have a 64bit machine, 32-bit software can be run on a 64-bit Operating System.

I used pip install opencv-python it worked for me https://pypi.python.org/pypi/opencv-python

Related

import is successful in jupyter notebook but fails with cmd

I installed torch using pip, and it went successfully! When I import it in jupyter notebook it is successfull. But when I try to use it cmd, it fails! any help?
Below is what shows on my cmd
C:\Users\my_pc_name>python
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'

Python module not found after installation

I'm trying to install the python module netcdf4. I seem to have been able to do this successfully, but then I get the "module not found error" when I try to import it in python. Having looked at some similar questions, I suspect the issue has something to do with the path, but I don't know what do about that. Here's what happens specifically:
(base) C:\Users\jwmil>conda install netcdf4
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
(base) C:\Users\jwmil>python
Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import netcdf4 as pc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'netcdf4'

Why opencv3 requires libavcodec56 although opencv2 requires libavcodec57

I have installed opencv using apt-get. I got opencv2 with the following version and it works fine:
rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ python2.7
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'2.4.9.1'
Then I wanted to install opencv on a conda environment using pip. I got the following version
(olfatf)rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ pip list | grep opencv
opencv-python 3.4.0.14
However, I get the following error when I import the module:
(olfatf)rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ python
Python 3.4.3 |Continuum Analytics, Inc.| (default, Aug 21 2015, 00:53:08)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.conda/envs/olfatf/lib/python3.4/site-packages/cv2/__init__.py", line 3, in <module>
from .cv2 import *
ImportError: libavformat.so.56: cannot open shared object file: No such file or directory
I checked the install libavcodec library and I get the version 57.
(olfatf)rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ ls | grep libavformat
libavformat.a
libavformat.so
libavformat.so.57
libavformat.so.57.56.101
So I want to know why a later version of opencv requires an older version of libavcodec. Also, how can I installed both libavcodec56 and libavcodec57 on my machine ?
I use a raspberry pi with Raspbian Strech
Its not that opencv requires it, Its that whoever compiled the binary of opencv you are using compiled it against libavcodec56. Easiest fix is to compile it yourself.
Also, how can I installed both libavcodec56 and libavcodec57 on my machine ?
Don't. just compile and link against the same version.

Python 3.6.1 OpenOPC install

Pardon me for my ignorance but I can't seem to get OpenOPC installed with Python 2.7 or 3.6.1. I found the github code but it does not appear to include an installer. So I attempted to install the version for 2.7 from here. I can make the OpenOPC server talk using the instructions but after copying all the files from the python 3 project into my python directory I can import OpenOPC but when I try opc = OpenOPC.client() I get a fault.
C:\>python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenOPC
>>> opc = OpenOPC.client()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'OpenOPC' has no attribute 'client'
>>>
It works fine for me. I have installed OpenOPC through that package thanks to pip:
pip install OpenOPC-Python3x
Hope it helps.

How to fix ImportError in PyQt5?

I install new version of Anaconda (Python 3.6) and now I can not import PyQt.
I reinstalled it three times and add <>\Anaconda3.6\Lib\site-packages\PyQt5\Qt\bin to PATH variable. But it did not help.
$ python
Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5.QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: Could not find the specified module
Try to add file python3.dll from python.org to your anaconda's directory.
In my case i had there only python36.dll

Categories

Resources