DLL load failed, DLLs not in right location - python

I have pygame 1.9.2 for Python 3.2+. However, when I try to start up Python with pygame, I receive: "ImportError: DLL load failed: The specified module could not be found." I found the files it needs, but where should I put them?
This is my full error traceback:
Traceback (most recent call last):
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\hg.py", line 1, in <module>
import pygame
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pygame\__init__.py", line 95, in <module>
from pygame.base import *
ImportError: DLL load failed: The specified module could not be found.

Most pygame errors in windows 10 are caused by having an out-of-date pygame by installing the compiled .exe version while not installing it from the official source, since their version is different from the PyPi index.
You will have to download the corresponding file suitable for your system from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Then do
pip install c:/path/to/the/wheelfile.whl

You must have installed pygame incorrectly or something went wrong during installation. I would uninstall pygame and reinstall it with the pip command.
Go to the search bar at the bottom left of your desktop (on your taskbar) and enter cmd. This will open the command line interface (CLI). Then go to here: https://pip.pypa.io/en/stable/installing/ and install the file get-pip.py. Once this has been completed, go to the cmd you opened earlier and enter python get-pip.py. This should install pip, setuptools and wheel.
After this, use the command below to install pygame:
pip install pygame
Then try a simple test to see if it works:
import pygame
print(pygame)

Related

Why cant I import/use installed libraries in Python

I recently downloaded Python 3.10 because I used 3.9. At first, everything worked fine. Sadly, I can't use installed libraries nor use newly downloaded ones, since I deleted Python 3.9. What can I do about this problem?
VSCode gives me this Error message:
Traceback (most recent call last):
File "e:\XXXX\XXXX.py", line 5, in <module>
from playsound import playsound
ModuleNotFoundError: No module named 'playsound'
You can check installed packages using this command:
pip freeze
or
pip list
Uninstall and install using command pip install <package-name>

python: installing pygame to every new project

I ran into some problems with some pip installations. I have found a way of installing that works, but I feel like it's wrong.
I installed pygame from the cmd prompt and got this message:
Defaulting to user installation because normal site-packages is not
writeable Requirement already satisfied: pygame in
c:\users\Somenewguy\appdata\roaming\python\python310\site-packages
(2.1.2)
But when I went to pycharm and started my project, I got this message:
Traceback (most recent call last):
File "C:\Users\Somenewguy\Python Projects\new\main.py", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
I then did the pygame pip installation from the terminal in pycharm. But this time I installed it directly into the project folder, and that approach worked.
This is the only way I can import pygame into my projects which I think is weird.
Why do I have to install this package for each project?
If you use a virtual-environment, this is the expected behavior. If you don't want to install it every time, use the system environnement.

DLL load failed: The specified module could not be found. File "<stdin>", line 1, in <module>

Installed anaconda 3 with python 3.7.1 and extracted openCV 3.4.5. Copied and renamed the cv2.cp37-win_amd64.pyd file from opencv(python3.7 folder) as cv2.pyd and pasted on Anaconda3/Lib/site-packages.
Tried installing opencv through anaconda navigator; installed visual C++ redistributable; tried through opencv-contrib-python; checked if the python3.dll is missing, but present. And none of these helped.
ImportError Traceback (most recent call last)
<ipython-input-2-252459bf3e0b> in <module>
----> 1 import cv2
ImportError: DLL load failed: The specified module could not be found.
I have seen some of these installation issues before and found the easiest solution to be pip. Instructions can be found here
If you already have pip installed, simply run pip install opencv-python from your command line. You may have to clean up some of your old installation attempts for this to work, but try it first and test it real quick with something like python -c "import cv2; print(cv2.__version__)". You should get something like 4.0.0 as a response.

Pygame "No module called pygame.base"

When I download pygame-1.9.2b8-cp36-cp36m-win32.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame I turn it into zip, take the headers in the pygame-1.9.2b8.data folder into pygame34/include/pygame and I put the other pygame file from the zip in the site-packages folder together with pygame-1.9.2b8.data as any tutorial shows, I always get this error:
Traceback (most recent call last):
File "C:/Users/andsa/PycharmProjects/THIS WORKS ANDREAS/Games.py", line 1, in <module>
import pygame
File "C:\Python34\lib\site-packages\pygame\__init__.py", line 141, in <module>
from pygame.base import *
ImportError: No module named 'pygame.base'
EDIT: I use python 3.4.5, I have tried both python and pygame 64 and 32 bit but i still get this error
This error bugged me for months, what i did was:
Uninstalled the package
pip3 uninstall pygame
Purged the pip cache
pip cache purge
Finally...Reinstalled pygame using pip3
pip3 install pygame
Worked like a charm :)
Use pip3 tool to reinstall the pygame python module:
C:\Python373\Scripts>pip3 uninstall pygame
C:\Python373\Scripts>pip3 install pygame
Then install it:
C:\Python373\Scripts>pip install pygame-menu==2.0.1
You probably have python installed for 32-bit. Uninstall and the install the 64-bit version. After that,
pip3 uninstall pygame
pip3 install pygame
try usin pip3 install pygames
to install pygames
pip3 install pygame
SUBLIME TEXT SOLUTION
OBS: THE REASON MOST GUI FRAMEWORKS DO NOT WORK ON SUBLIME IS BECAUSE OF THIS ONE LITTLE DETAIL HERE
Create a new build system:
In Sublime go to >> Tools
Tools >> Build System
Build System >> New Build System
DELETE EVERYTHING CONTAINED IN THIS NEW FILE AND ADD THIS PIECE OF CODE:
{
"cmd": ["/usr/local/bin/python3.8", "-u", "$file"],
"file_regex": "^[]*File \"(...*?)\", line ([0-9]*)"
}
ATTENTION: DO NOT CHANGE THE CURRENT DIRECTORY YOU ARE ON, WHICH IS THE
USER ONE.
SAVE IT AS Python3.8.sublime-build
In Sublime go to >> Tools
Tools >> Build System
Mark the Python3.8 you have just created
Voila!
P.S I Saved mine as 3.7 but it works the same, as long as the code inside the file is 3.8, or whatever version you have on your machine currently.

Python 3.5 I can't install Pillow

I have installed Python 3.5.0rc3 amd64 and I need to install Pillow. So I downloaded it from http://www.lfd.uci.edu/~gohlke/pythonlibs/ Pillow‑2.9.0‑cp35‑none‑win_amd64.whl and I've also installed by pip successfully. But when I'm typing in interpreter from PIL import Image I got the following message:
File "C:\Program Files\Python 3.5\lib\site-packages\PIL\Image.py", line 63, in <module>
from PIL import _imaging as core
ImportError: DLL load failed: The specified module could not be found.
Moreover when I uninstalled this package and I was trying to install by easy_install I got another error:
Couldn't find a setup script in C:\Program Files\Python 3.5\Scripts\Pillow‑2.9.0‑cp35‑none‑win_amd64.whl.
What can I do?
Try this command on the command line:
python -m pip install pillow

Categories

Resources