I installed Python 3.1 and the Pygame module for Python 3.1. When I type import python in the console I get the following error:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pygame
File "C:\Python31\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.
It could be due to the architecture of your OS. Is your OS 64 Bit and have you installed 64 bit version of Python? It may help to install both 32 bit version Python 3.1 and Pygame, which is available officially only in 32 bit and you won't face this problem.
I see that 64 bit pygame is maintained here, you might also want to try uninstalling Pygame only and install the 64 bit version on your existing python3.1, if not choose go for both 32-bit version.
Looks like the question has been long ago answered but the solution did not work for me. When I was getting that error, I was able to fix the problem by downloading PyWin32
I had installed Python 32 bit version and psycopg2 64 bit version to get this problem. I installed psycopg2 32 bit version and then it worked.
Had this issue on Python 2.7.9, solved by updating to Python 2.7.10 (unreleased when this question was asked and answered).
Another possible cause of similar issue could be wrong processorArchitecture in the cx_freeze manifest, trying to load x86 common controls dll in x64 process - should be fixed by this patch:
https://bitbucket.org/anthony_tuininga/cx_freeze/pull-request/71/changed-x86-in-windows-manifest-to/diff
Related
I've been trying to run a bot for Super Hexagon (Just for fun), but when I try to run the module in IDLE 2.7.11 (32 bit) I get the error
Traceback (most recent call last) :
File "C:\Users(Me)\Desktop\Super-Hexagon-Bot\super_hexagon_bot.py", line 8, in < module >
import win32ui
ImportError: No module named win32ui
Unfortunately, right now I'm streaming my desktop to my Macbook, so I can't copy the code, but here's an image of the part the program has an error with.
I have 64 bit Windows 8, so the win32ui is most likely the problem, but I'm not sure how to change the code to accomodate 64 bit. Any suggestions?
I think the problem is not the the BIT version from your Windows PC.
It seems to me, that you have not installed he module win32ui.
After searching the web, I have found, the module pywin32, which should include all necessary WIN thinks.
You can install it via pip, easy_install of with these MSI installer:
http://sourceforge.net/projects/pywin32/files/pywin32/
Please use the newest and correct version.
But I think you have to change the code:
Sorry I have no Windows PC, so I could not try it, maybe something like that:
from pywin32 import *
It's most likely the Python libraries you are using here, is causing the issue. There is 64 bit build for python win32ui.
http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/
Download and install one of then and set the build path and import accordingly.
In order to start building a gui I've decided to install wxPython, however I can't get it working. I run python 2.7.6 (in IDLE it shows: Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win32) and it works fine.
When I however try to install a 32 bit or 64 bit version of wxPython from http://www.wxpython.org/download.php it doesn't work, meaning that when I run:
import wx
I get the following message:
Traceback (most recent call last):
File "C:\Users\****\Desktop\Python GUI test\test1.py", line 2, in <module>
import wx
ImportError: No module named wx
I think it might go wrong with the place where it installs wxPython. Normally however it uses the right directory automatically. It tries to install in the following dir:
C:\Users\****\AppData\Local\Enthought\Canopy32\User\Lib\site-packages
Which is in a program called Canopy which I once installed but don't know how to get rid off. I've installed it in this dir and I've also installed it within the dir where Python is installed:
C:\Python27\Lib\site-packages
Both of these locations don't work.
Anyone has an idea where things go wrong?
I would suggest to clean up your installations. Canopy is part of Enthought, so if you don't need this anymore de-install it, I would think you can do that from: Control Panel\All Control Panel Items\Programs and Features
Then re/install the Python version you want to use, would suggest 2.7.8 32 bit and then install wxPython 3.0.1 32 bit for Python 2.7.
To test it do not use "Idle" as it is written in Tkinter, which will cause conflicts with wxPython. Just test it with
c:\Python27\python.exe
import wx
I am trying to install and use PyGame. I am using Python 3.3.2 and Pygame "3.3 pygame-1.9.2a0" according to the installer. I downloaded it from https://bitbucket.org/pygame/pygame/downloads. I used an easy install, and after next-next type install, I opened the Python 3.3.2 Shell and typed "import pygame". I got this error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pygame
ImportError: No module named 'pygame'
>>> import sys; print sys.path
SyntaxError: invalid syntax
I am also trying to install it with the PyCharm IDE, but I have NO clue how to do that either. The installer I'm using may be for 32 bit, which wouldn't be compatible with my 64 bit installation of Python, but I don't know how to tell and if so is there even a 64 bit version of PyGame for 64 bit? If anyone knows how to install PyGame for Python 3.3.2 please let me know. Thank you for your time.
If your python is a 64 bit version the binary install for the 32 bit will not work. However, there is a 64 bit version here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
If you're worried because they're unofficial don't. I have used many installations from that link for my 64 bit python and they're working great.
Currently, pygame is not available for 64 bit Python (or so it seems on Pygame Site).
The one you installed maybe 32 bit & thus causing the ImportError.
In Python 3.x, print is a function & hence the SyntaxError.
Pycharm for Python 3.x is available Pycharm Download
I would recommend using Python 3.x (32 bit) because most of the libraries seem to be compatible with it & also, 64 bit version doesn't provide much performance benefit as such.
I personally use PyScripter IDE
This maybe very handy at times - Very useful precompiled binaries for several libraries
From pygame website:
windows 64bit users note: use the 32bit python with this 32bit pygame.
So either donwload a 32bit python, then install with the 32bit pygame installer, or download the unofficial 64bit pygame build at here.
Ever time I use PyCharm, I go to File > Settings > Project: (project name) > Interpreter > Plus Icon > (search pygame and click install package) This is because I think that you are using a pycharm venv and I think that that isolates outer packages so I do it this way
I'm on a MacBook Pro running Snow Leopard 10.6.8 and Python 2.7.2. I went on the pygame website, downloaded and installed all the required frameworks and programs, compiled and installed pygame, but I cant import the module into python. I downloaded an example program off of the pygame website and every time I run it I get this error:
Traceback (most recent call last):
File "/Users/jesse/Downloads/PurpleMines/PurpleMines.py", line 3, in <module>
from pygame import *
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
I'm guessing its a problem having to do with running a 64-bit OS?
Thanks in advance for the help.
Removing the old pygame install and reinstalling did the trick for me.
I'm running Mac OS 10.7
sudo rm -Rf /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame
Then copy and install pygame from:
http://www.pygame.org/ftp/pygame-1.9.2pre-py2.7-macosx10.7.mpkg.zip
While what Sylvain said above is correct, this error is often caused by differences in bit rate between python and pygame. It is possible that redownloading it only helps because you get the correct distribution that time. To tell the bit rate of python, do this:
import platform
platform.architecture()
If it is 32 bit, get a 32 bit distribution of pygame. Otherwise, get a 64 bit distribution.
I downloaded and installed this version of wxPython for use with my Python 2.6 installation:
http://downloads.sourceforge.net/wxpython/wxPython2.8-win32-unicode-2.8.9.1-py26.exe
When I run Python and try to import wx, I get the following error:
C:\Program Files\Console2>python
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.py", line 45, in <module>
from wx._core import *
File "c:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 4, in <module>
import _core_
ImportError: DLL load failed: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.
>>>
I have already tried removing wxPython and installing again and I got the same error. How can I fix this problem?
I was getting the same error.
After some googling found this link to MSVC++ 2008 Redestributable and installed it.
That solved the problem.
Hate to say this, but I had the same problem, and and import worked fine after a reboot.
Copy the Microsoft C runtime library v.9 files and manifest. That is, msvcr90.dll and microsoft.vc90.crt.manifest from folder python to the folder wx, tha is, folder which contains failed to start DLLs.
Or install the Visual C++ 2008 Redistributable Package.
From looking for "application configuration is incorrect" in the wxPython trac system, the only reference that might make sense is a 64-bit vs 32-bit compatibility issue.
Otherwise, I'd say Brian's answer of trying ANSI is pretty good.
BTW, if you try uninstalling again, make go into the site-packages folder and make sure all the wx and wxPython stuff is deleted.
Try the ANSI version instead of the Unicode one. IIRC it needs to match the Python 2.6 install to work properly.
I too have the same issue.Better install "Portable Python" IDE which comes with some nice modules including wxPython .You can start coding GUI immediately without the need to download a separate wxPython.The link ,
http://www.portablepython.com/
Maybe too late, but I had the same problem and solved that by downloading that from their own website : wxPython2.8-win64-unicode-py27
In my case it initially wanted to setup in somewhere else than my python folder. So I changed it to be in ../python27/Lib/SitePackages/
Then it worked properly.
I hope it helps.
Another late answer, but I recently had issues (8/14) and my solution was to use the 32-bit instead of 64-bit wxPython version.
you try to use the module wxpython 2.8.12.1 version, select the version of your python. you can download it here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#wxpython