"no matching architecture in universal wrapper" when importing pygame - python

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.

Related

Importerror on win32ui for 32 bit Python

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.

MySQL does not work after installation [duplicate]

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

How to import pygame.locals successfully

Hello there Stackoverflowers,
I am learning how to program with Pygame and I am trying to import pygame.locals
According to the tutorial I am learning from, I am starting of as such;
import pygame, sys
from pygame.locals import *
I get this error message:
Traceback (most recent call last): File "C:/Python33/test.py", line 2, in from pygame.locals import * ImportError: No module named 'pygame.locals'
I have downloaded Pygame (binary package) for Python 3.2, and I am currently running 3.3.
When I import pygame in the Python shell, no error is returned, and thus I am lead to believe that Pygame was successfully installed.
I am running Windows 7 64 Bit.
I've seen a similar post regarding pygame.locals and Raspberry Pi and Linux, so I think this post is still relevant. Let me know if it is not.
My guess is that you have a file named pygame.py in the current directory in which you are running you script.
I found that on Windows 7 64-bit, you need to get Python 3.3.5, as well as the pygame-1.9.2a0-hg version from Bitbucket.
This solved the problem ImportError: No module named 'pygame.locals' for me.
(Somehow it's a bit weird that the pygame website doesn't provide latest versions of pygame.)
yes #Bartlomiej Lewandowski, you were right.I also faced the same problem and came here to resolve it. I did not download any newer version as apt-get install was giving the message that this is the newest version.
I just renamed my file pygame.py to some other random name.
It is working fine now. So the problem was we named our file as pygame.py, Which is restricted in pygame module, I am not sure. But its working fine now.
Thanks Bartlomiej Lewandowski once again.
For RedHat I needed to install
yum install SDL-devel-1.2.14-7.el6_7.1.x86_64

Can not import Pygame

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

Run wxPython on Lion

I've just bought a new computer with Lion on it. I've downloaded and installed both Python 2.7 and wxPython 2.8 (for 2.7). I know Python comes with the system, but I rather go with the official one.
Anyway, upon typing "import wx" on the IDLE, I get the following message:
Traceback (most recent call last):
File "", line 1, in
import wx
File "/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/init.py", line 45, in
from wx._core import *
File "/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core.py", line 4, in
import core
ImportError: dlopen(/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/core.so, 2): no suitable image found. Did find:
/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/core.so: no matching architecture in universal wrapper
I believe it happens because wxPython only supports 32-bit, but I can't figure out how to force python to run on 32-bit.
Anyone could help?
Thank you in advance.
wxPython 2.9 supports 64-bit on Mac too (see the Development version section and look for the cocoa build: http://wxpython.org/download.php). This was also discussed on the mailing list, and multiple users confirmed that wx works on Lion: https://groups.google.com/forum/#!searchin/wxpython-users/lion/wxpython-users/LvjSVqqMMpQ/U0QJXEeBpLQJ
This may not work for python versions below 2.9. Running 'python' did not work for me...I am using 2.7 for compatibility. But figured out that 'python' may be an alias for a 64 bit mode and for some reason the arch command does not work.
So, here is what I have to use under Lion to get wx to work (this works for 2.6 or 2.7):
$ arch -i386 python2.7
Then when python loads:
import wx
works fine. You may have to call the specific python with the arch command, such as python2.7, or whatever version you are using.
This should start it up in 32-bit mode, I'm not sure if it will fix the wx problem
% arch -i386 python
You can force python to run in 32-bit mode by adding the following line to your shell profile
export VERSIONER_PYTHON_PREFER_32_BIT=yes

Categories