'ImportError: DLL load failed:' in pygame module - python

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pygame
File "C:\Program Files (x86)\Python35-32\lib\site-packages\pygame\__init__.py", line 127, in <module>
from pygame.base import *
ImportError: DLL load failed: The specified module could not be found.

Ensure that the version of PyGame you're using matches the version of Python you're using!

You have not installed Pygame correctly or not in the correct directory/file. What python version do you use and is your computer 32/64 bit?
Thx

This is a late answer, but may be it helps someone.
The pygame binary you use should be built for the Python version you have in your system.
In your case, you seem to have 32-bit Python3.5.
There is no official pygame binary for Python3.5 yet. But unofficial binaries are available here.
Download pygame-1.9.2b1-cp35-cp35m-win32.whl from the link (this is the 32-bit version for 32-bit Python3.5), and install it using pip.
Example: cd to the folder where you downloaded the .whl file, and run C:\Program Files (x86)\Python35-32\Scripts\pip install pygame-1.9.2b1-cp35-cp35m-win32.whl
Note:
pip may not play well when the python install directory has spaces. So please install python in a path without spaces. For example, C:\Python35-32 instead of C:\Program Files (x86)\Python35-32.
Also, see this answer in case you need more info on installing .whl files.

Related

ImportError Pyo

I'm trying to import pyo in python3.8.8 and I'm not getting any results. When I try to run the command:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import pyo
File "C:\Users\andre\AppData\Roaming\Python\Python38\site-packages\pyo_init_.py", line 28, in
from .lib import analysis as analysis
File "C:\Users\andre\AppData\Roaming\Python\Python38\site-packages\pyo\lib\analysis.py", line 32, in
from ._core import *
File "C:\Users\andre\AppData\Roaming\Python\Python38\site-packages\pyo\lib_core.py", line 58, in
from .._pyo import *
ImportError: DLL load failed while importing _pyo: Impossibile trovare il modulo specificato.
How can I solve this?
I assume you are on windows. What version of pyo do you have installed? I saw that it was only version 1.0.1 that python 3.8 support was introduced. Try uninstalling pyo, then make sure you install the newest version. Also, did you install with pip? If you did, try installing from their downloadable releases on github. What code did you write that caused this error? I need to see your code.
Looks like you're using pc032 (032bit) Python. Last PyO version with pc032 (on Win) support is [PyPI]: pyo 1.0.1 (from 191127). But I didn't see the Python 3.8 .whl among files (neither for a couple of older versions).
Just out of curiosity: how did you install PyO?
In order to get things going either:
Switch to pc064 (064bit) Python
Use a (pc032) Python version that prebuilt .whl exists for
I've built v1.0.4 (latest at answer time) and placed the .whls at [GitHub]: CristiFati/Prebuilt-Binaries - (master) Prebuilt-Binaries/PyO/v1.0.4. Download and install the preferred one (check [SO]: Installing pygraphviz on Windows 10 64-bit, Python 3.6 (#CristiFati's answer) (at the end) for more details about the process)

OpenCV in Python: "ImportError: DLL load failed"

So many questions already about this topic, but I didn't find any satisfying answer about the "DLL not found" traditional issue.
I'm using Python 3.5 installed via Anaconda 3;
I have installed with pip the 'official' opencv_python-3.2.0.6-cp34-cp34m-win_amd64.whl (right from here https://pypi.python.org/pypi/opencv-python);
Windows version is 7 - 64 bits;
I have uninstalled all the redistributable VC++ that were present on my machine and reinstalled its 2015 version - so the famous as well as mandatory DLL msvcp140.dll is present on my laptop;
the cv2 module is present in the Lib/site-packages directory;
it contains, among others, file 'cv2.cp35-win_amd64.pyd'.
Meanwhile, I still can't get access to cv2:
>>> import cv2
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import cv2
File "C:\Program Files\Anaconda3\lib\site-packages\cv2\__init__.py", line 7, in <module>
from . import cv2
ImportError: DLL load failed: The specified module could not be found.
Modifying the name of the .pyd --> cv2.pyd does not solve the problem, nor does the installing via pip of the unofficial but great wheel version from Gohlke (http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv)
Any idea about what is going on?
As mentioned in the comment which I didn't notice at first, you can resolve this by installing from the unofficial site (Gohlke)
(http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv)
I uninstalled the official one by calling:
pip uninstall opencv-python
And then downloaded the .whl package from the mentioned site (you need to carefully choose the correct python version and the correct processor architecture x86 or x64).
And then, go to the path where the .whl file is downloaded and call:
pip install opencv_python-x.x.x-cpxx-cpxxm-win_xx.whl
Regarding the comment in the question, always remove any existing opencv package before installing another one because, opencv from unofficial and official sites will be considered as 2 packages by pip.
You can install official opencv if you follow my answer here. You get that error because of a problem with Anaconda.
But if you install official opencv it will autocomplete and give suggestions in your python IDE (see this). So, if you need autocomplete as well, you need to go with unofficial opencv.
I had the same issue. This helps me:
conda install -c menpo opencv3
Found at https://www.scivision.co/install-opencv-python-windows/

Not able to import Python packages

Not able to install any packages
I've tried VLC package from https://wiki.videolan.org/python_bindings
and got a traceback.
Now I am trying pygame module and this is what i get
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pygame
File "C:\Users\Vineeth\AppData\Local\Programs\Python\Python36-32\lib\pygame\__init__.py", line 133, in <module>
from pygame.base import *
ImportError: DLL load failed: The specified module could not be found.
Please help i am pretty new to python
There are some release binaries for Python3.x, 64bit Windows at http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
I suggest you download it from that site and install it. It works for me. If you are using Windows ,it is a good way to install some packages,like lxml matplotlib.
Also you check out this question.
Hope this helps.
I tried to execute your statements and the imports worked fine for me. I have a 64bit Windows OS. And my python version Python 3.5.2 - 64bit.
Check if you have other Python versions, if you have removed them, make sure you did that right.
Ultimately I would just suggest you to do pip install pygame. The version compatibility will be handled by pip itself.

Lost module while installing opencv 2.4.9 for python in Windows

I try to install opencv from source. I use Visual studio 2010, python 2.7.8 and make steps like here.
The problem is that when importing cv2 I get error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
ImportError: DLL load failed: The specified module could not be found.
There are following cv-files in the C:\Python27\Lib\site-packages:
cv2.pyd
cv.py
cv.pyc
I also have Python 3.4.1 but CMake doesn't see that, so I think it is not the reason.
But CMake has just two lines in the PYTHON group:
PYTHON_NUMPY_INCLUDE_DIR C:/Python27/lib/site-packages/numpy/core/include
PYTHON_PACKAGES_PATH C:/Python27/Lib/site-packages
Here's what my install of OpenCV for Windows, built with MinGW for C++ includes.
It's not actually an install - the folder can be zipped and put on any computer, provided you specify to CMake the paths.

Pygame help 2.7

I have installed pygame for python 2.7 but this come up if I type import pygame
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pygame
File "C:\Python27\lib\site-packages\pygame\__init__.py", line 95, in <module>
from pygame.base import *
ImportError: DLL load failed: %1 is not a valid Win32 application.
Please help me
According to pygame download page NOTE:
windows 64bit users note: use the 32bit python with this 32bit pygame.
Make sure you're using 32bit version of Python.
I have had this problem recently, i have found that if you are using a 64 bit machine, then you need the 64 bit version of python and the 64 bit version of pygame. The 64 bit version of pygame is not available on the main website but you can download it from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/
I would suggest uninstalling python 2.7 and reinstall the 64 bit version of it from the python download page. when you install pygame, use the file called "pygame‑1.9.2a0.win‑amd64‑py2.7.exe" (without the quotes) on http://www.lfd.uci.edu/~gohlke/pythonlibs/
Good luck.
I had this problem and solved it. I found a 64 bit pygame version at http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Select pygame-1.9.2a0-cp27-none-win_amd64.whl (for python 2.7) from the list of options available.
Copy the downloaded file to path/to/python27/Scripts
Then use pip installer.
Install wheel package first if you don't have it already. It is used to extract and install whl files.
Open cmd.
cd path/to/python27/Scripts
pip install wheel
pip install pygame-1.9.2a0-cp27-none-win_amd64.whl
Hope that solves it.

Categories