Importing Pygame: Strange DLL Error - python

I've recently downloaded Pygame for the first time on this computer. When I try to run a script that uses "import pygame" it gives me this error:
Traceback (most recent call last):
File "graphs.py", 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.
Any help would be greatly appreciated.

This error message almost always implies you are using an extension module containing a compiled DLL for a 64-bit version of Python but you're running a 32-bit version of Python. Or vice-versa.

Related

Unable to import OpenCV even after successful installation for Python 3.7.6 (ImportError: DLL load failed: The specified module could not be found.)

I have tried reinstalling all versions of Pythons and OpenCVs but for my use case, I need to stick with Tensorflow 1.15.0 which is supported by Python version 3.7.x. (with all the necessary MS VS C++ build tools with Visual Studio version 2019 also reinstalled to be safe)
So for now, I have Python 3.7.6 with opencv-contrib-python==4.5.2.52 installed on my machine at the moment. And for all combinations of Python and OpenCV, I simply get the below error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\aadak\AppData\Local\Programs\Python\Python37\lib\site-packages\cv2\__init__.py", line 5, in <module>
from .cv2 import *
ImportError: DLL load failed: The specified module could not be found.
I was wondering if anyone else has faced this particular sequence of error in line # 5 of __init.py__ and how one can rectify this error.
Thanks in advance. :)

how to fix "from mediapipe.python._framework_bindings import resource_util ImportError: DLL load failed: The specified module could not be found."

When I try to import the mediapipe module which I successfully installed using "pip install mediapipe" I'm getting this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user_name\Anaconda3\envs\env_name\lib\site-packages\mediapipe\__init__.py", line 16, in <module>
from mediapipe.python import *
File "C:\Users\user_name\Anaconda3\envs\env_name\lib\site-packages\mediapipe\python\__init__.py", line 17, in <module>
from mediapipe.python._framework_bindings import resource_util
ImportError: DLL load failed: The specified module could not be found.
I am using the anaconda terminal and jupyter notebook to run the codes and my OS is Windows 10. I have tried multiple solutions I found online but none of them worked for me. Any help will be greatly appreciated. Thank you!
There you type in your terminal pip install msvc-runtime to avoid the error.
Than it will work fine. If you want to know more about mediapipe visit:
https://google.github.io/mediapipe/
Thanks.

DLL files error in using pytorch

I add pytorch via pip installation and now I'm trying to use it, but have this dll error:
Traceback (most recent call last):
File "F:/Python/Projects/1.py", line 2, in <module>
import torch
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\__init__.py", line 78, in <module>
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
I install msvcp71 and msvcr71 dll files but it's not worked!
You can use Dependency Walker to find out which dependency of that DLL might be missing. Use it to open the Python extension file that's failing to load. The file name should be something like:
C:\Users\Saeed\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\_C.pyd
Another common cause is a DLL for Python 64-bit while using Python 32-bit or vice-versa. But you installed with pip so it should be OK. Nevertheless, it's a good idea to verify this is not the case.

Pygame installation error; Missing DLL

I've recently started learning python. So I installed pygame into Python folder and when I try to import it in SHELL it gives me this error:
> Traceback (most recent call last): File "<pyshell#0>", line 1, in
> <module>
> import pygame File "C:\Python34\lib\site-packages\pygame\__init__.py", line 99, in
> <module>
> from pygame.base import * ImportError: DLL load failed: The specified module could not be found. I was installing python-3.4.3 and
> pygame-1.9.2a0.win32-py3.2
To install pygame you run the .msi binary, not in the python folder specifically. The error above says that you have installed part of pygame, but not all of it correctly.
ImportError: DLL load failed: The specified module could not be found.
Python is saying that the run file is installed, but not other modules of pygame are in their correct location. My advice is remove whatever pygame files are installed and re-install pygame, but not python.
Edit: I would put this as a comment, but as I have just joined stack overflow I can't comment so I added extra information to create an answer.

Trouble installing Pygame on a Mac

I've installed Python 2.7 and Pygame on my Mac, but every time I try to 'import pygame', I get this error message:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pygame
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/__init__.py", line 95, in <module>
from pygame.base import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so: no matching architecture in universal wrapper
What am I doing wrong?
This is a typical architecture issue. Try a
file /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so
If one of the result lines includes your architecture (e.g. i386), then the problem is not from the package itself, but from the way you launched it. Try then to launch it from a 32 bits instance of Python:
python2.7-32
>>>import pygame
NB: you can guess your architecture with
uname -m

Categories