I'm using python 2.7.2 and windows 7. I searched through internet, helps and other sources but i can't find an answer to my problem.
One of my source imports tkinter, and this one imports _tkinter. At this moment it say ImportError DLL load failed:
Traceback (most recent call last): File "NERO/show_image.py", line 13,
in <module> import Tkinter File "C:\Python27\lib\lib-tk\Tkinter.py", line 38,
in <module> import FixTk File "C:\Python27\lib\lib-tk\FixTk.py", line 65,
in <module> import _tkinter ImportError: DLL load failed: %1 is not a valid Win32 application.
2012-Jan-04 12:27:21.889374 (M) [python] Finished process
I searched _tkinter and i found it in Python27/libs as a lib file.
On many sites it says to install tk/tcl or tkinter, but I don't find a separate installation for windows.
Using Windows x86 MSI Installer (2.7) from http://www.python.org/getit/releases/2.7/. In windows 7 64-bit. The python version is 32 bit.
I had a similar problem importing Tkinter on Windows 7 64-bit - seems that the 64-bit library was still in the libs folder from a previous 64-bit python install.
Uninstalling 64-bit python properly and then repairing with the 32-bit installer fixed the problem for me - you don't need to use 64-bit python.
Re-install Python.
If this still doesn't work, there is another simple solution:
Uninstall your current python. Delete Python27 folder entirely from your C: drive.
Download and install the 64-bit version of Python from http://www.python.org/download/.
Next time do not mix your 32-bit application with 64-bit OS whenever a 64-bit choice for the application is available!
I was getting this error while trying to use matplotlib in a simple application.
Uninstall Python and remove its folder from your C-Drive.
Download and Install 64bit python.
Follow this to install pip on your machine.
http://www1.cmc.edu/pages/faculty/alee/cs40/penv/installFlaskOnWindows.html
This was finally what worked for me
I had the same issue and was able to uninstall Python 2.7 (using the Windows 7 'uninstall' service) and then reinstall it from here:
python-2.7.6.msi
Also, if you're concerned about ensuring 64bit conformance across your python libraries then you may find the following library list site to be a great resource. It has numerous 64bit versions of python libraries.
Please don't reinstall Python for this. A simple fix can resolve this issue as below:
Find the matplotlibrc file at Python27\Lib\site-packages\matplotlib\mpl-data\matplotlibrc
Open using notepad
Change the backend parameter to 'backend: Qt5Agg'
And it will be solved. No need to reinstall.
SOLVED without reinstalling anything:
1-add these 3 lines to your setup.py :
...
import os
os.environ['TCL_LIBRARY']= r'C:\<your python folder>\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\<your python folder>\tcl\tk8.6'
...
setup(
...
)
2- copy tcl86t.dll and tk86t.dll from C:\<your python folder>\DLLs to <your project folder>(where you have batch file, setup.py).
3- add "include_files": ["tcl86t.dll", "tk86t.dll"] to option in your setup.py, something like:
options= { 'build_exe':{'packages':[.....], "include_files": ["tcl86t.dll", "tk86t.dll"]}},
note: if you didn't find tcl86t.dll and tk86t.dll in DLLs folder as mentionned in step 2, then try again to search for it,but using research tab in DLLs folder this time.
I had a similar problem. My Python version was 2.7.12 and 64bit and I was using Windows 10, 64bit OS.
I tried to import Tkinter and what I got back was
ImportError: DLL load failed: %1 is not a valid Win32 application
I uninstalled Python and removed all traces of it. I then installed Python 2.7.14 (32bit) and this seems to have solved my problem. I don't get this error message any longer.
I have a lot of installed python packages on my machine so I did not want to unistall and reinstall the whole python, I did as follow and the problem was solved:
Change your C:\Python27 home folder to another name, for example C:\Python27_old
Install a new Python27 on your computer (32 bit)
Copy tcl and DLLs folder from the fresh installed python to the old one (Before this step make a copy of tcl and DLLs of C:\Python27_old to recover it if you face any problem in the next steps)
C:\Python27\tcl Copy and replace to C:\Python27_old
C:\Python27\DLLs Copy and replace to C:\Python27_old
Delete the C:\Python27
Rename the C:\Python27_old to the C:\Python27
Please pay attention to get a backup form your tcl and DLLs folder to recover it in case you face any further problem.
Removing 64 bit python and doing a repair on 32 bit python worked for me. OS: 64 bit Windows Server 2008.
I also met this issue, because I use 64-bit python. Maybe python 64-bit doesn't have a good support.
My way is to solve it:
Uninstall python 64-bit.
Install python 32-bit.
Uninstall the 64-bit package. pip uninstall xxx.
Install the 32-bit package. pip install xxx.
For Windows 10,
Uninstall all versions of Python
Install Python 3.x (your latest version) with PATH variable
python -mpip install -U matplotlib
Install Python x.x (your other versions) without PATH variable
Done. Try running your scripts again.
If Python was installed by OsGeo4W then you should also install the python-tcltk and/or python3-tcltk packages in the OsGeo4W setup tool.
Related
In [windows server 2012 R2 x64, python 3.7 64x]
pip install opencv-contrib-python
installed without any error .
and when I try to import it
import cv2
show me this error :
Traceback (most recent call last):
File "test.py", line 1, in <module>
import cv2
File "C:\Program Files\Python37\lib\site-packages\cv2\__init__.py", line 3, in
<module>
from .cv2 import *
ImportError: DLL load failed: The specified module could not be found.
and I see another topic about this error but their solution does not work for me :
- DLL load failed error when importing cv2
- Failure to import cv2 in python : DLL load failed
- and a lot of pages in here
some of them say about that problem because anaconda, and I don't have anaconda even. and many say that problem 32 or 64 version, I try both and disappointment. many about system variables...
what dll failed to load? cv2? why?
what i try till now:
change python version : 3.5, 3.7, 2.7 in 86x and 64x (uninstall complete last version and delete all remain files in program files ... then install new one)
try with another packages like : opencv-python, opencv-contrib, try install specific versions with .whl (in some topic i read about this so install numpy-1.14.5+mkl-cp37-cp37m-win_amd64.whl and opencv_python-3.4.3+contrib-cp37-cp37m-win_amd64.whl but anything not change)
import numpy before cv2 for every test
installed Microsoft Visual C++ 2015 Redistributable Update 3 , 2008 , 2010 , 2017 for 64x
UPDATE
NEXT 2 DAY
I try to manage missing dll base on dependency walker that mention in bellow post, download all dll and put them in system 32, its a good clue but not solve the problem.
DAY 4,5
my next step , trying compile OpenCV in my machine , install visual studio 2012 + cmake and base on document compile 2 version , 64x and 32 , compiling have a lot of problem itself (like missing some lib from c lang and need to install Visual C++ Redistributable for Visual Studio 2012 ...) and I resolve all of them ,then I have 2 success compiled version but both have the same problem with missing dll, the compile process is so slow and give 2 day from me. so if fail on this mission :/ I search for a new way...
DAY 6
my next step is to try to run OpenCV in my machine with docker ( I try but docker windows just install on windows 10 and windows server 2016) so I search for an alternative. I found Vagrant that work like docker but with VM (visual box) today my time spend for this articles, it's amazing, the concept of docker and vagrant is so Attractive, and I play with this like that I have new puzzle :)
first error show on ... and limitless errors go on :
Day 7
Vagrant tests failed too because my windows server 2012 is a vb machine (visual server) and run a visual box in another visual box impossible!
so I need new clues :
Day 8-9
try install vagrant with VMware , I download VMware, unfortunately this plugin is not free (79$) so I try to work with pythonanywhere.com that 'gives you access to machines with a full Python environment already installed.' in this free account, you can't openurl with urllib , and more limit...
so I wanna try to install ubuntu in VMware my self... I read here results after work. it's Impossible with same reason vb (visual box)
This can happen if you are using windows 10 N distribution, the N distributions does not come pre installed with windows media feature pack, which is required after OpenCV version 3.4 and onwards.
The preferred solution is to install the feature pack at : https://www.microsoft.com/en-us/software-download/mediafeaturepack
Be careful to choose the version that works with your current version of windows.
If that is not an option, fall back to an earlier version of OpenCV that does not have dll dependencies, you can do that by:pip install opencv-python=3.3.0.9
Since windows rolled out it's N version this problem has been seen at many places, and has many impacts across the windows environment, the fastest way to identify if you have this problem is open youtube in Edge browser, if it says HTML5 media plugin not found, this is the problem.
Update May 2020: There is a new way to install media pack for Windows 10 N.
https://support.microsoft.com/en-us/help/4562569/media-feature-pack-for-windows-10-n-may-2020
I had the same error (although I compiled OpenCV myself), in my case there were some DLL dependencies missing. You can check that with the program Dependency Walker.
Download Dependency Walker and run it, and open the file cv2.pyd with Dependency Walker, it should be in C:\Program Files\Python37\lib\site-packages\cv2\ if the pip package installed correctly.
This program then scans for dependencies (which may take a few minutes) and it then shows missing DLL files in red.
I have faced the similar issue in Windows Server 2012 r2. After lot of findings I found that mfplat.dll was missing which is related to Window Media Service.
Hence you have to manually install the features so that you can get dll related to window media service.
Turn windows features on or off
Skip the roles screen and directly go to Feature screen
Select "Desktop Experience" under "User Interfaces and Infrastructure"
After this all required dll of opencv would be available.
Python 3.7 may not support some modules.
Try installing python 3.6.4
Using command prompt, "pip install
opencv" or "pip install opencv-python"
Import cv2
Can you try uninstalling opencv and installing it using a wheel file instead? Here is a website that has many versions of OpenCV compiled for windows, search for the one you need and simply install it with pip command.
So if you have Python 3.6 (64 Bit) and wish to install OpenCV 3.4.3 then download the wheel file:
opencv_python‑3.4.3‑cp36‑cp36m‑win_amd64.whl
I had similar issue except that I'm using Anaconda3 and this code here solved it:
conda install -c anaconda py-OpenCV
After 15 days of brain storming, This solution worked for me. And I am sure that it will work for you too. I installed anaconda to use OpenCV 3.1.0. I followed following Steps:
1) I have installed anaconda-5.3 64-bit installer (614.3 MB) which uses python 3.7. You can download anaconda from link: https://www.anaconda.com/download/#windows
2) After installation of anaconda, open anaconda prompt by typing "anaconda prompt" on windows start button. Open with "Run as administrator".
3) You have to create new environment to install and use OpenCV module.Write following commands to create and activate new environment:
>conda create --name myNewEnv python=3.5.0
>activate myNewEnv
"myNewEnv" is the name of new enviroment.
4)Now you need to install prerequisite for OpenCV, which is numpy and then install opencv3. Start internet before executing following commands:
>conda install numpy
>conda install anaconda-client
>conda install --channel https://conda.anaconda.org/menpo opencv3
5)OpenCV3 has been installed. Now, verify installation by executing following commands:(myNewEnv) C:\Users\Nilesh> python
>>>import cv2
>>>cv2.__version__
Follow steps given below, when you want to start OpenCV3 second time onwards:
1) Open "anaconda command promt" from start menu with "run as administrator" rights
2) Type command >activate your_new_environment_name
3) Assume that you want to run file located on desktop, for that write following command:
> cd C:\Users\Nilesh\Desktop
4) Now your working directory is Desktop.
5) Type following command to run any code (for example test.py).
> python test.py
Note: Here, python means version-3.
I hope this solution will work for you.
I had the same problem on Windows Server 2012 R2 x64. I was creating executable file using PyInstaller and got error in runtime:
ImportError: DLL load failed: The specified module could not be found.
After installing "Visual C++ redistributable" 2015 and enabling "Media Foundation" feature my problem was resolved.
There is more informations in documentation: OpenCV Documentation
I was having this problem on Windows. I resolved this error by checking instructions here.
Q: Import fails on Windows: ImportError: DLL load failed: The specified module could not be found?
A: If the import fails on Windows, make sure you have
Visual C++ redistributable 2015 installed.
If you are using older Windows version than Windows 10 and latest system updates are not installed, Universal C Runtime might be also required.
Windows N and KN editions do not include Media Feature Pack which is required by OpenCV. If you are using Windows N or KN edition, please install also Windows Media Feature Pack
i was suffering from the same problem "DLL load failed" after reading tons of answers and articles i got a solution.
i don't know this works for you or not but give it a try.
tools and versions i used: anaconda - 5.3.1, python - 3.7, win 10 (64 bit)
Steps i performed :
step1:i installed opencv 3.4.4 from here
then extract into C drive (you can do wherever you want)
step2: copy cv2.pyd file from [C:\opencv\build\python\cv2\python-3.7] here to [C:\Users\"user-name"\Anaconda3\Lib\site-packages] here.
step3: run dependency walker to detect which dll files are missing,
after running dependency walker in my case it showed two dll files are not loading, they are (1)OPENCV_WORLD344.DLL and (2)IESHIMS.DLL.
i don't know about your situation but you can do this-> find files name using dependency walker then find their path and follow step4.
step4: open System property->Advanced->Environment variables, now edit path and add C:\opencv\build\x64\vc14\bin (in my case this was the place where OPENCV_WORLD344.DLL is stored) and after doing this, import cv2 in python.
If my answer does not work then add a comment.
It helps me pip install opencv-contrib-python Anaconda Prompt, python 3.7.1 cv2 4.1.1
I was having the same issue. I resolved this error by downgrading open cv.
pip install opencv-python==3.3.0.9
its worked well for me.*
Answer is Need to put cv2.pyd file to your virtual environment.
need to put under two folder of envs,
first is under DLLS folder and
Second is under Lib/site-packages
To get cv2.pyd > download from this link https://sourceforge.net/projects/opencvlibrary/ and then extract the download file
You will get opencv folder, after that go inside opencv folder like Downloads\opencv\build\python\2.7 and go one deeper folder depend on your 32 or 64 window version
Copy cv2.pyd Important **** after copying cv2.pyd file to your envs, you need to rename cv2.pyd to _cv2.pyd
I was having this problem on Windows Server 2008R2 fresh install and took almost a day to resolve, as was trying with many hits and trials finally I found solution somewhere in internet (not stackoverflow)
Installed Windows Media Feature Pack for 2008R2 then installed Server Manager-> Features-> Add Features-> Desktop Experience
Server Manager-> Features-> Add Features-> Desktop Experience
and Ink and Handwriting Services.
Besides check list includes
Visual C++ redistributable 2015
Universal C Runtime
Hopefully its will help save time
Installing Python version 3.6 and then installing opencv with the command:
pip install opencv-python==3.3.0.9 resolved this issue for me
All you need is python 3.6.
I've been looking for solution for last 3 days and my problem was solved when i installed python 3.6.7.
After installing python 3.6 you can simply run pip install opencv-python.
Source: https://www.geeksforgeeks.org/setup-opencv-with-pycharm-environment/
Just ran into this problem of cv2 importable from my conda environment but not through the "same" environment in jupyter. The error I was getting was that it couldn't load the dll.
Additionally, I could not get opencv installed through jupyter, even using:
import sys
!conda install --yes --prefix {sys.prefix} numpy
I checked my path using:
import os
os.path
in both my shell and jupyter. They were the same(!).
I was finally able to get things working by running the command:
conda install nb_conda
in my conda environment, as outlined here: https://github.com/udacity/P1_Facial_Keypoints/issues/13
This was eye opening as it created a new install of jupyter note books associated with my env instead of anaconda, with five(!) environments to choose from when creating a page. There were three that seemed to be associated with my conda environment. Interestingly, now it only shows the one named environment as an option when creatin a new notebook again in jupyter (the one associated with the env), but it successfully imports cv2.
For a good read on why this is happening with jupyter:
https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/
Came here from Windows 10N, upgraded to Windows 11. Had to install Media Feature Pack under Settings -> Apps -> Optional Features -> Add an optional feature.
Windows settings
I have installed opencv on my windows machine using python 3.6 without any issues, using:
pip install opencv-python
but when I try to import cv2 I get the following error
ImportError: DLL load failed: The specified module could not be found.
I have seen this post
It says cv2 doesn't work with python 3 I was wondering if this has been fixed or if there is a way around it
I took a lot of time to solve this error!
Run command
pip install opencv-contrib-python
You can download the latest OpenCV 3.2.0 for Python 3.6 on Windows 32-bit or 64-bit machine, look for file starts withopencv_python‑3.2.0‑cp36‑cp36m, from this unofficial site. Then type below command to install it:
pip install opencv_python‑3.2.0‑cp36‑cp36m‑win32.whl (32-bit version)
pip install opencv_python‑3.2.0‑cp36‑cp36m‑win_amd64.whl (64-bit version)
I think it would be easier.
Update on 2017-09-15:
OpenCV 3.3.0 wheel files are now available in the unofficial site and replaced OpenCV 3.2.0.
Update on 2018-02-15:
OpenCV 3.4.0 wheel files are now available in the unofficial site and replaced OpenCV 3.3.0.
Update on 2018-06-19:
OpenCV 3.4.1 wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7 support, and replaced OpenCV 3.4.0.
Update on 2018-10-03:
OpenCV 3.4.3 wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7 support, and replaced OpenCV 3.4.1.
Update on 2019-01-30:
OpenCV 4.0.1 wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7 support.
Update on 2019-06-10:
OpenCV 3.4.6 and OpenCV 4.1.0 wheel files are now available in the unofficial site with CPython 3.5/3.6/3.7 support.
Update on 2023-02-11:
OpenCV 4.5.5 wheel files are now available in the unofficial site with CPython 3.7/3.8/3.9/3.10/3.11 support.
If you are using Anaconda with python 3.5, this is a problem in the Anaconda release. (Refer this issue)
You can fix this issue by copying python3.dll file to Anaconda3 folder (where python.exe is located)
How to get "python3.dll"
In cmd, type python --version to find whether your installation is 64-bit or 32-bit
download python 3.x embeddable zip file from here
Extract the zip file and copy python3.dll file to Anaconda3 folder
But if you can move to Anaconda with python 3.6 you will not face this issue. If it is possible for you, then it is the recommended way..
Recently I have faced the similar issue in Azure Windows Server 2012 r2 . Tried all option with and without Anaconda but none of them helped. After lot of findings I found that mfplat.dll was missing which is related to Window Media Service.
Hence you have to manually install the features so that you can get dll related to window media service.
1.Turn windows features on or off
2.Skip the roles screen and directly go to Feature screen
3.Select "Desktop Experience" under "User Interfaces and Infrastructure"
After this all required dll of media services for opencv would be available.
So if you are planning to run your code in cloud(Window Server) then please dont forget to select Desktop Experience feature.
I ran into this problem on Windows 10 (N) with a new Anaconda installation based on Python 3.7 (OpenCV version 4.0). None of the above advice helped (such as installing OpenCV from the unofficial site nor installing VC Redistributable).
I checked DLL dependencies of ...\AppData\Local\conda\conda\envs\foo\Lib\site-packages\cv2\cv2.cp37-win_amd64.pyd using dumpbin.exe according to this github issue. I noticed a library MF.dll, which I figured out belongs to Windows Media Foundation.
So I installed Media Feature Pack for N versions of Windows 10 and voilà, the issue was resolved!
After spending too much time on this issue and trying out all different answers, here is what found:
The accepted answer by #thewaywewere is no longer applicable. I think this was applicable when opencv-python module still wasn't available.
This is indeed a bug in Anaconda 4.2 because they forgot to ship python3.dll. They have fixed this in next releases but unfortunately 4.2 is the last release with Python 3.5 as default. If you are stuck with Python 3.5 (for example VS2015 is only aware of versions up to 3.5) then you must manually download python3.dll as described in answer by #Ramesh-X.
If you can move on to Python 3.6 (which at present bit difficult if you are using OpenCV and VS2015) then just install latest Anaconda version and you don't have to deal with any of these.
There are many questions on that and many suggestions. None of them helped me for the recent Opencv 3.4.16 and Python 3.6/3.7.
Finally I switched to Pyhon 2.7.15 and installed opencv 3.1.0. The DLL-problem was solved.
When I look in cv2.pyd with dependency walker, the 3.1 has no dependency to one missing dll. Opencv 3.4 has this missing dependency to this dll:
API-MS-WIN-DOWNLEVEL-SHLWAPI-L1-1-0.DLL
may be this is the problem.
P.S.: I have Win7 pofessional 64Bit, 32Bit Python 2.7.15
Frankly there are a lot of very smart and complicated answers here. Mine is dumb and simple. I deleted my conda environment, re-installed from scratch, taking pains to install opencv first. This fixed my problems. Environments are meant to be temporary and diaphanous -- don't get too attached.
So if my environment was called fubar first make sure every instance is deactivated (including any IDEs that are using it). Then remove it:
conda remove --name fubar --all
Now I simply recreate my environment and add opencv first:
conda create --name fubar
conda activate fubar
conda install opencv
And then go from there. First open python and make sure import cv2 works. Then you should be on your way. Note I always (always) install Spyder last as it tends to screw things up when I don't.
Note, if that doesn't work, we have had some cases where people have to uninstall and reinstall Anaconda, and then things worked. Obviously a last resort.
In my case a major update of Windows 10 removed some Windows packages, so other methods (reinstalling opencv etc.) did not help. To fix it, install:
a) Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019
b) Media Feature Pack for N versions - needed only if you have Windows 10 N
Both need restart of PC.
I had the same issue when installing opencv 2.4.13 on Anaconda3 (Python 3.6)... I managed to fix this issue by reverting to Anaconda2 (Python 2.7)
this happens because the compiler or the interpreter is finding more than one package of the file, delete all the number of same package you have and then keep only one and then try to install. It serves
The issue is due to the missing python3.dll file in Anaconda3.
To fix the issue, you should simply copy the python3.dll to C:\Program Files\Anaconda3 (or wherever your Anaconda3 is installed).
You can get the python3.dll by downloading the binaries provided at the bottom of the Python's Release page and extracting the python3.dll from the ZIP file.
I had the same issue with python 3.6(Anaconda3) and OpenCV 3.4.1 for spyder to work. Even after copying cv2.pyd into Anaconda3 Users/home/Anaconda3/Lib/site-packages, it didn't work.
But found a solution
Later I installed OpenCV and Dlib on Anaconda and copied the generated cv2.cp36-win_amd64.pyd and dlib.cp36-win_amd64.pyd into Anaconda3 Users/home/Anaconda3/Lib/site-packages. These can be copied from environment folder C:\Users\home\Anaconda3\envs\opencv\Lib\site-packages.
Finally spyder started to work
I managed to get it to work by installing python 3.9.12 in a new environment (using conda), and then installing opencv in that environment. Because of my python version, opencv version 4.5.5 was installed instead of version 4.60.
(I had already updated VC2015-2022 and added the python3.dll to PATH; neither of these worked.)
I have the same problem. when I install WinPython programming, and run opencv after copy the cv2.pyd file from my opencv directory, it will be like this: C:\Users.....\Downloads\opencv\build\python\2.7\x64, x64 or x86 is depend on your 32 or 64 bit devices. and paste to C:\Users.....\Downloads\WinPython-64bit-3.5.4.1Qt5\python-3.5.4.amd64\Lib\site-packages, I prefer the previous python 3.5 than 3.6. Because when I "import cv2" installed (python 3.6) it shows directly: "ImportError: DLL load failed: The specified module could not be found"
Then I install python 3.5 and open WinPyhton Command prompt and type "pip install opencv-python".
The command prompt download opencv automatically, it shows the process like this "Successfully installed opencv-python-3.3.0.10"
Finally, I try to run open cv by type "import cv2", it works
i try to type "cv2.version", and shows: '3.3.0'
Under Winpython : the Winpython-64bit-.../python_.../DLLs directory the file cv2.pyd should be renamed to _cv2.pyd
(base) C:\WINDOWS\system32>conda install C:\Users\Todd\Downloads\opencv3-3.1.0-py35_0.tar.bz2
I ran this command from anaconda terminal after I downloaded the version from
https://anaconda.org/menpo/opencv3/files
This is the only way I could get cv2 to work and I tried everything for two days.
If this helps someone, on official python 3.6 windows docker image, to make this thing work I had to copy following libraries from my desktop:
C:\windows\system32
aepic.dll
avicap32.dll
avifil32.dll
avrt.dll
Chakra.dll
CompPkgSup.dll
CoreUIComponents.dll
cryptngc.dll
dcomp.dll
devmgr.dll
dmenterprisediagnostics.dll
dsreg.dll
edgeIso.dll
edpauditapi.dll
edputil.dll
efsadu.dll
efswrt.dll
ELSCore.dll
evr.dll
ieframe.dll
ksuser.dll
mf.dll
mfasfsrcsnk.dll
mfcore.dll
mfnetcore.dll
mfnetsrc.dll
mfplat.dll
mfreadwrite.dll
mftranscode.dll
msacm32.dll
msacm32.drv
msvfw32.dll
ngcrecovery.dll
oledlg.dll
policymanager.dll
RTWorkQ.dll
shdocvw.dll
webauthn.dll
WpAXHolder.dll
wuceffects.dll
C:\windows\SysWOW64
aepic.dll
avicap32.dll
avifil32.dll
avrt.dll
Chakra.dll
CompPkgSup.dll
CoreUIComponents.dll
cryptngc.dll
dcomp.dll
devmgr.dll
dsreg.dll
edgeIso.dll
edpauditapi.dll
edputil.dll
efsadu.dll
efswrt.dll
ELSCore.dll
evr.dll
ieframe.dll
ksuser.dll
mfasfsrcsnk.dll
mfcore.dll
mfnetcore.dll
mfnetsrc.dll
mfplat.dll
mfreadwrite.dll
mftranscode.dll
msacm32.dll
msvfw32.dll
oledlg.dll
policymanager.dll
RTWorkQ.dll
shdocvw.dll
webauthn.dll
wuceffects.dll`
Please Remember if you want to install python package/libraries for windows,
you should always consider Python unofficial Binaries
Step 1:
Search for your package, download dependent version 2.7 or 3.6 you can find it under Downloads/your_package_version.whl its called python wheel
Step 2:
Now install using pip,
pip install ~/Downloads/your_packae_ver.whl
this will install without any error.
I had the same problem and spent 3 full days wrestling with it. I tried everything suggested: upgrading pip, updating Visual C++, updating Anaconda, manually downloading files and basically every solution I could find on the web. Here's what finally worked maybe it'll help someone else:
1- I ditched Python 3 and Anaconda-based downloads since I noticed they had several problems and downloaded Python 2.7.16 64-bits instead.
2- Navigated to where Pip was located on my drive (for me the path is C:\Python27\Scripts) highlighted the path by selecting it, and typed "cmd" then enter so the Command Prompt opens on that path (I noticed skipping this usually brings about a couple errors)
3- Updated Pip using python -m pip install --upgrade pip on the CMD (again, skipping this and not updating it didn't let this procedure go through)
4- Downloaded the appropriate Wheel file from https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv (after trying several the one that worked for me was opencv_python-2.4.13.7-cp27-cp27m-win_amd64.whl) I copy-pasted it to the same folder Pip was in (C:\Python27\Scripts for me) and then installed it through CMD using: pip install opencv_python-2.4.13.7-cp27-cp27m-win_amd64.whl. Always through CMD opened on that path as showed in step 2
5- After step 4 when I imported OpenCV using import cv2 I didn't have the DLL error anymore but an error related to numpy (since I had just installed that version of Python and so Numpy wasn't installed yet). I installed numpy by typing pip install numpy and voilà ! The problem was solved and OpenCV imported correctly.
Hope this helps someone.
In my case, I had to install an older version of openCV (windows 10, Python 3.6.8)
pip install opencv-python==3.3.0.9
This error can be caused by missing the following dll
To have this dll install:
https://www.microsoft.com/en-us/software-download/mediafeaturepack
as already explained above
Running python 3.8.8 from windows 10 powershell from an anaconda 4.10.1 environment I installed opencv with
conda install opencv
I could import opencv no problem when I launched python from the command line.
However, when I tried to run code from inside pydev using the python interpreter for the specific anaconda environment I had activated, pydev couldn't find whichever dll it was looking for when importing opencv.
Setting the following environment variable resolved the issue:
CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1
Source: PyDev/Eclipse not loading _mklinit when run from a Conda environment
Which points to this trouble shooting description for a different library loading issue: https://docs.conda.io/projects/conda/en/latest/user-guide/troubleshooting.html#numpy-mkl-library-load-failed
If you are using a server or docker enviroment without a gui (e.g. Windows Core Server) make sure that you use the headless version of cv2:
pip install opencv-contrib-python-headless
I had the same problem, it seems openCV requires Windows Media Feature pack which is not installed on Windows 10 N by default, please install it using the following link:
https://www.microsoft.com/en-us/software-download/mediafeaturepack
Windows 11 N
This a final fix for the people who don't use anaconda.
simply there are missing DLL files, that's it
download the latest version of
https://sourceforge.net/projects/opencvlibrary/
Then after you extract it search for .dll files and copy all of them and paste into C:\Windows\System32 and approve for replacing.
That's it !
Install python using:
pip install opencv-python(It will take the latest version)
Make sure opencv-python is installed in path(\Python\Python36\Lib\site-packages),
you will find cv2 folder over there.
To check the version of cv2:
import cv2
print(cv2.__version__)
ImportError: DLL load failed: %1 is not a valid Win32 application
Does anyone know how to fix this? This problem occurs when i am trying to import cv2. My laptop is 64bit and installed 64bit python, i also put the cv2.pyd file in the site-packages folder of Python.
My PYTHONPATH value = C:\Python35;C:\Python35\DLLs;C:\Python35\Lib;C:\Python35\libs;C:\Users\CV\OpenCV\opencv\build\python\2.7\x64;%OPENCV_DIR%\bin;
My OPENCV_DIR value = C:\Users\CV\OpenCV\opencv\build\x64\vc12
I also put reference of my pythonpath and my opencv_dir to the PATH by putting **%PYTHONPATH%;%PYTHONPATH%\Scripts\;%OPENCV_DIR%;**
I also installed opencv_python-3.0.0+contrib-cp35-none-win_amd64 through pip install and command line.
None of this solved my problem.
A bit more elaborate answer for people coming here (like me) in the future:
Uninstall opencv-python, e.g. via pip uninstall opencv-python
Uninstall all visual studio c++ packages
Download the new visual studio from microsoft and install
Download your matching python whl from gohlke and install using e.g. pip install opencv-python-3.2.0+contrib
Now it should work...
(Posting #eryksun comment as a community answer to prevent system from autodeleting question)
Gohlke's cv2.cp35-win_amd64.pyd depends on MSVCP140.dll, the C++
runtime library.
Was that the DLL you need?
The installer for Python
3.5 doesn't include this DLL, so in that case you probably had to install the VC++ 2015 redistributable package.
This can happen if you are using windows 10 N distribution, the N distributions does not come pre installed with windows media feature pack, which is required after OpenCV version 3.4 and onwards.
The preferred solution is to install the feature pack at : https://www.microsoft.com/en-us/software-download/mediafeaturepack
Be careful to choose the version that works with your current version of windows.
If that is not an option, fall back to an earlier version of OpenCV that does not have dll dependencies, you can do that by:pip install opencv-python=3.3.0.9
Since windows rolled out it's N version this problem has been seen at many places, and has many impacts across the windows environment, the fastest way to identify if you have this problem is open youtube in Edge browser, if it says HTML5 media plugin not found, this is the problem.
If the problem still persists, Install dependency walker and find out which modules are causing dependency breaks.
in this case, I just copy file 'python3.dll' from my python3 installation folder to my virtualenv lib folder, and then it works.
I have a situation very much like the one at Error "ImportError: DLL load failed: %1 is not a valid Win32 application", but the answer there isn't working for me.
My Python code says:
import cv2
But that line throws the error shown in the title of this question.
I have OpenCV installed in C:\lib\opencv on this 64-bit machine. I'm using 64-bit Python.
My PYTHONPATH variable: PYTHONPATH=C:\lib\opencv\build\python\2.7. This folder contains cv2.pyd and that's all.
My PATH variable: Path=%OPENCV_DIR%\bin;... This folder contains 39 DLL files such as opencv_core246d.dll.
OPENCV_DIR has this value: OPENCV_DIR=C:\lib\opencv\build\x64\vc11.
The solution at Error "ImportError: DLL load failed: %1 is not a valid Win32 application" says to add "the new opencv binaries path (C:\opencv\build\bin\Release) to the Windows PATH environment variable". But as shown above, I already have the OpenCV binaries folder (C:\lib\opencv\build\x64\vc11\bin) in my PATH. And my OpenCV installation doesn't have any Release folders (except for an empty one under build/java).
What's going wrong? Can I tell Python to verbosely trace the loading process? Exactly what DLL files is it looking for?
I noticed that, according to http://www.dependencywalker.com/, the cv2.pyd in C:\lib\opencv\build\python\2.7 is 32-bit, whereas the machine and the Python I'm running are 64-bit. Could that be the problem? And if so, where can I find a 64-bit version of cv2.pyd?
Unofficial Windows Binaries for Python Extension Packages
You can find any Python libraries from here.
Please check if the Python version you are using is also 64 bit. If not then that could be the issue. You would be using a 32-bit Python version and would have installed a 64 bit binaries for the OpenCV library.
Wow, I found yet another case for this problem. None of the above worked. Eventually I used python's ability to introspect what was being loaded. For Python 2.7, this means:
import imp
imp.find_module("cv2")
This turned up a completely unexpected "cv2.pyd" file in an Anaconda DLL directory that wasn't touched by multiple uninstall/install attempts. Python was looking there first and not finding my good installation. I deleted that cv2.pyd file and tried imp.find_module("cv2") again and python immediately found the right file and cv2 started working.
So if none of the other solutions work for you, make sure you use Python introspection to see what file Python is trying to load.
In my case, I have 64-bit Python, and it was lxml that was the wrong version--I should have been using the x64 version of that as well. I solved this by downloading the 64-bit version of lxml here:
https://pypi.python.org/pypi/lxml/3.4.1
lxml-3.4.1.win-amd64-py2.7.exe
This was the simplest answer to a frustrating issue.
I just had this problem. It turns out it was just because I was using an 64-bit version of the OpenCV file. I tried the x86 and it worked.
I had the same problem. Here's what I did:
I downloaded the pywin32 wheel file from here, then
I uninstalled the pywin32 module. To uninstall, execute the following command in a command prompt.
pip uninstall pywin32
Then, I reinstalled pywin32. To install it, open the command prompt in the same directory where the pywin32 wheel file lies. Then execute the following command.
pip install <Name of the wheel file with extension>
Wheel file will be like: piwin32-XXX-cpXX-none-win32.whl
It solves the problem for me.
I copied cv2.pyd file from /opencv/build/python/2.7/x86 folder instead of from /x64 folder to C:/Python27/Lib/site-packeges. I followed rest of the instructions provided here.
Added by someone else, not verified: I also copy file cv2.pyd to folder C:/Python27/Lib/site-packages/cv2. It works.
For me the problem was that I was using different versions of Python in the same Eclipse project. My setup was not consistent with the Project Properties and the Run Configuration Python versions.
In menu Project → Properties → PyDev, I had the Interpreter set to Python 2.7.11.
In Run Configurations → Interpreter, I was using the Default Interpreter. Changing it to Python 2.7.11 fixed the problem.
If your build system (CMake in my case) copies the file from <name>.dll to <name>.pyd, you will get this error if the original file wasn't actually a DLL file. In my case, building shared libraries got switched off, so the underlying file was actually a *.lib.
I discovered this error by loading the pyd file in Dependency Walker and finding that it wasn't valid.
Update NumPy.
pip install numpy --upgrade
It works for me!
This one worked for me:
pip install -- pywin32==227
I faced the same issue when I uninstalled and reinstalled a different version of 2.7.x of Python on my system using a 32-bit Windows Installer. I got the same error on most of my import statements.
I uninstalled the newly installed Python, downloaded a 64-bit Windows installer, reinstalled Python again, and it worked.
So I had problems installing vtk under Windows (as I use Python 3.7, there isn't any binary available so far. Just for older Python versions pip install vtk is not working)
I did wrote Python in my cmd:
Python 3.7.3 on win32
So I now know I have Python 3.7.3 running on a 32 bit.
I then downloaded the correct wheel at VTK‑8.2.0‑cp37‑cp37m‑win32.whl
Next I installed that wheel:
pip install VTK-8.2.0-cp37-cp37m-win32.whl
Then I tested it and it worked:
python
import vtk
I experienced the same problem while trying to write code concerning speech-to-text.
The solution was very simple. Uninstall the previous pywin32 using the pip method:
pip uninstall pywin32
The above will remove the existing one which is by default for 32 bit computers. And install it again using
pip install pywin32
This will install the one for the 64 bit computer which you are using.
I had a similar issue while trying to run uvicorn,
Creating a new virtual environment and reinstalling the python packages worked
You can install opencv from official or unofficial sites.
Refer to this question and this issue if you are using Anaconda.
It has a very simple solution.
After installing opencv
place
cv2.pyd from C:\opencv\build\python\2.7\ **x64** to C:\Python27\Lib\site-packages
instead of, place cv2.pyd from C:\opencv\build\python\2.7\ **x86** to C:\Python27\Lib\site-packages
I got this error when trying to import MySQLdb.
What worked for me was to uninstall Python and then reinstall it.
I got the error after installing npm (https://www.npmjs.com/get-npm). One thing it did was install Python even though I already had it.
First I copied cv2.pyd from /opencv/build/python/2.7/x86 to C:/Python27/Lib/site-packeges. The error was
"RuntimeError: module compiled against API version 9 but this version of numpy is 7"
Then I installed numpy-1.8.0-win32-superpack-python2.7.exe and OpenCV works fine.
>>> import cv2
>>> print cv2.__version__
2.4.13
Please make sure that you have installed a Python 2.7.12 or below version. Otherwise you will definitely get this error.
Make sure the Oracle client is 64 bit installed if the OS is 64 bit.
Make sure the Microsoft Visual C++ compiler for Python 2.7 is 64 for bit for a 64 bit OS or 32 bit for 32 bit.
Note: If your OS is 64 bit, install all packages of 64 bit or if the OS is 32 bit, install the 32-bit package.
This has worked for me. I have tried different methods, but this was my best solution.
Open a command prompt and type the following;
pip install opencv-python
(Make sure your Internet connection is on.)
After that, try importing it again.
It could also be that your Anaconda version is 32 bit when it should be 64 bit.
If you are using pycharm I go to settings -> python interpretation and click the + button and search for the name on the list of python packages there
An image showing where to go when you want to install something
I found the solution. Maybe you can try to use the cmd window rather than the Anaconda prompt window to start your first Scrapy test.
I'm trying to install said library for use with Python. I tried downloading the executable installer for Windows, which runs, but says it doesn't find a Python installation. Then tried registering (http://effbot.org/zone/python-register.htm) Python, but the script says it can't register (although the keys appear in my register).
Then I tried downloading the source package: I run the setup.py build and it works, but when I run setup.py install it says the following:
running install
running build
running build_py
running build_ext
building '_imaging' extension
error: Unable to find vcvarsall.bat
What can I do?
UPDATE (May 2014): Like said by some comments and answers, PIL is currently unmantained, and the way to go now is to use Pillow (https://pypi.python.org/pypi/Pillow/, pip install pillow).
I found a working win7 binary here: Unofficial Windows Binaries for Python Extension Packages It's from Christoph Gohlke at UC Irvine. There are binaries for python 2.5, 2.6, 2.7 , 3.1 and 3.2 for both 32bit and 64 bit windows.
There are a whole lot of other compiled packages here, too.
Be sure to uninstall your old PILfirst.
If you used easy_install:
easy_install -mnX pil
And then remove the egg in python/Lib/site-packages
Be sure to remove any other failed attempts. I had moved the _image dll into Python*.*/DLLs and I had to remove it.
I've just had the same problem (with Python 2.7 and PIL for this versions, but the solution should work also for 2.6) and the way to solve it is to copy all the registry keys from:
HKEY_LOCAL_MACHINE\SOFTWARE\Python
to
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python
Worked for me
solution found at the address below so credits should go there:
http://effbot.slinkset.com/items/Adding_Python_Information_to_the_Windows_Registry
Compiling PIL on Windows x64 is apparently a bit of a pain. (Well, compiling anything on Windows is a bit of a pain in my experience. But still.) As well as PIL itself you'll need to build many dependencies. See these notes from the mailing list too.
There's an unofficial precompiled binary for x64 linked from this message, but I haven't tried it myself. Might be worth a go if you don't mind the download being from one of those slightly dodgy file-upload sites. Other than that... well, you could always give up and instead the 32-bit Python binary instead.
If you installed a win64 python, you need a win64 PIL. The official PIL download site only has win32, as far as I can tell. The win32 installer will not see your 64-bit python installation.
No amount of tinkering with permissions or redistributables will fix this. You could use the win32 python instead (the Win64 python is mutant anyhow; Microsoft decided that C 'long' should be 32 bits in their 64-bit world, so python 'ints' are only 32 bits in Win64 python).
Since sizeof(long)!=sizeof(ptr) in win64, porting C extensions can be problematic, and will not be the same as porting them to linux 64. E.g. it seems that Win64 numpy is experimental/broken whereas linux64 numpy has been fine for years. My recommendation is if you use win64, stick with win32 python. If you want 64-bit python use linux.
I think I had a similar problem in the past, with another python library. I believe that it was a windows permission issue. Try adding "Users" to your python directory, and give them full access.
Make sure you have the Visual C++ Redistributable package installed on your machine.
Just got this error msg on my 32 bit Windows - I read the FAQ here: http://pythonware.com/products/pil/faq.htm and this sort of indicates that Windows is funny. Looked again at install pg and downloaded the Windows executable for Python26 # Python Imaging Library 1.1.7 for Python 2.6 (Windows only) - and the _imaging module gets installed when you run this. Should solve problem. So you can't just do the python setup.py install routine on: Python Imaging Library 1.1.7 Source Kit (all platforms) (November 15, 2009).
I was having the same problem so I decided to download the source kit and install it according to how you posted above...
Downloaded Source Kit
Opened command prompt on that folder and typed python setup.py build
Then I typed python setup.py install
It worked perfectly!
Now, some notes: when I typed python setup.py build, I saw that Microsoft Visual Studio v9.0 C compiler was being used to build everything.
So probably it's something with your compiler not correctly configured or something...
Anyways, that worked with me so thank you!
Pillow is new version
PIL-1.1.7.win-amd64-py2.x installers are available at
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil
http://www.lfd.uci.edu/~gohlke/pythonlibs/
press contrl F
type Pillow‑2.4.0.win‑amd64‑py3.3.exe
then click and downloadd the 64 bit version
Pillow is a replacement for PIL, the Python Image Library, which provides image processing functionality and supports many file formats.
Note: use from PIL import Image instead of import Image.
PIL‑1.1.7.win‑amd64‑py2.5.exe
PIL‑1.1.7.win32‑py2.5.exe
Pillow‑2.4.0.win‑amd64‑py2.6.exe
Pillow‑2.4.0.win‑amd64‑py2.7.exe
Pillow‑2.4.0.win‑amd64‑py3.2.exe
Pillow‑2.4.0.win‑amd64‑py3.3.exe
Pillow‑2.4.0.win‑amd64‑py3.4.exe
Pillow‑2.4.0.win32‑py2.6.exe
Pillow‑2.4.0.win32‑py2.7.exe
Pillow‑2.4.0.win32‑py3.2.exe
Pillow‑2.4.0.win32‑py3.3.exe
Pillow‑2.4.0.win32‑py3.4.exe