pygame not working with portable python - python

I'm trying to get pygame working with portable python 3.2.1.1 running off a USB stick, but when I use the following code:
import pygame, sys
It says:
ImportError: No module named pygame
My understanding was that pygame came embedded in portable python. Can anyone help?

Pygame does not come embeded in portable python 3.2.
Tho it comes in the 2.7 version.
Sources:
http://portablepython.com/wiki/PortablePython3.2.1.1 - 3.2 (No pygame here!)
http://portablepython.com/wiki/PortablePython2.7.3.1 - 2.7 (Pygame embeded!)

Running Pygame on Portable Python....
On Windows 7 download and copy the msi file into your portable directory. Double-click the msi file. When prompted for the directory, change to the USB drive. Once done, copy the library and site packages contents to the USB library and site packages.
To test, bring up Python interpreter, then type "import pygame".
If successful, you will not receive an error when importing.

Related

Not able to import Tkinter in Maya 2014

I am using windows 7 and Autodesk Maya 2014.When i am trying to import Tkinter i am getting error.please tell me how to solve error given below ?
How to install any python package in Auto desk Maya 2014 ?
import Tkinter
Error
Error: line 1: ImportError: file C:\Program Files\Autodesk\Maya2014\Python\lib\lib-tk\FixTk.py line 65: DLL load failed: %1 is not a valid Win32 application
I added a few Python modules to Maya with the "addsitedir-trick" explained at the end but not every python module will be playing nicely with Maya.
Python on Windows is built with Visual Studio 2008 Professional. Maya uses it's own Python interpreter but Autodesk builts Maya with another Visual Studio version. This can lead to problems if you insall python modules and try to use them with Maya. Beatuifully explained here (together with a the hard solution of compiling the wanted modules yourself):
http://p-nand-q.com/python/building-python-27-with-vs2010.html
What you can try: Install Python 2.7 on your Windows-box, install the module you want to access in Maya (eg with pip). Now in Maya add your system SitePackages (where you just installed the module to) to your Maya-Python-Interpreter SitePackages like so:
import site
site.addsitedir("/path/to/your/python27/Lib/site-packages")
Even cleaner solution would be to use a virtualenv instead of the global site-packages folder! (That's at least what i have done to get psycopg2 and requests play with Maya)
But as mentioned in the beginning of this answer there is a possibility that this may fail (with strange errors).
By the way: I highly recommend to use pyside instead of Tkinter if you want to do GUI stuff in Maya. Or the Maya-Wrappers preferably via pymel. (http://help.autodesk.com/cloudhelp/2017/ENU/Maya-Tech-Docs/PyMel/ui.html)

Pygame on Yocto

I've been trying to install the python library for making games, pygame, in my yocto image of linux for my raspberry pi 2. I have a python code of a game, I've run it in raspbian and it runs pretty slow, but it runs. Now in my image of linux I already have python but I have failed in installing the pygame library. Every time I tried to run the game it says "Error: import pygame", so clearly the problem is in the way I install the library.
I would appreciate any kind of help.
Did you check your PYTHONPATH is set ?
To set it, do:
export PYTHONPATH=/opt/ros/indigo/lib/python2.7/site-packages
You can add this line to your .profile or .bashrc

Installing Python/PyGame on mac

I've been trying to install PyGame with little success. I downloaded the
pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg
version of PyGame from this link and installed it using the wizard, but when I typed import pygame into the IDLE I got the following message.
$ import pygame
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 did I do wrong?
Also, what are the prerequisites for PyGame? I'm doing all this on a new computer and I've hardly downloaded anything.
I'm running OS X Version 10.8.2.
I know this thread is a little old, but thought I'd share my experience on this subject...
I'm using a 64-bit MacBook Pro running OS Mavericks and python 2.7.
Steps:
If you've installed a few different versions of pygame while trying to get the darn thing to import and work successfully, make sure you delete/uninstall all of these to get a fresh start. I did a simple search in the terminal to see where all of the various pygame folders where located:
In Terminal: sudo find / -iname "pygame"
The results show a list of all the pygame directories, these are the folders that you want to delete. Note, I created a new tab in terminal to do this so I can reference the directories from the search on the previous tab and easily copy each directory without having to do another search to remember where they are:
In Terminal: sudo rm -R -i path/pygame
Also note, you can take the -i out of the above code and it won't confirm the deletion of certain files, but BE REALLY CAREFUL when deleting full directories from the terminal.
Once your machine is clean of all previous pygame installations, make sure you have python 2.7 from python.org, NOT IDLE (default Mac Python Interpreter)! This is very important. I use PyCharm and it rocks! Also, choose the version that works on a 32-bit machine and 64-bit machine - this way you won't have issues with the pygame 32-bit installer on your 64-bit machine. I tried same installation process but with the 64-bit only python 2.7 installation and it didn't work. Link provided below:
Download 32/64-bit Python 2.7
Next, download the 32-bit pygame file for OS X 10.3 and beyond and run the mpkg file created from the dmg. Link provided below.
Download pygame 1.910 release for python 2.7
You should now have a working pygame installation in your python 2.7 package library. Enjoy.
Did you install python from python.org? Or use the one that came with OS X?
If you used the one supplied by Apple, you must download the one from python.org first, then install using that package. Or you can try the Lion-pygame package (the link is at the bottom of the Macintosh section of the download page), but it may be incompatible.
Did you download python 64-bit or python 32-bit?
This can cause major problems if you don't have the right one, if you have 64-bit you can download pygame 64-bit from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

Using Pygame without installing

I'm making a real simple RPG game at college and I would like to use pygame. However, my college has a group policy disabling any Windows executables from running so I can't install pygame. Is there any way I can just import pygame by just having it in the same folder?
One thing I do with external python libraries is to download the source, build it and copy the built library into ${PROJECT_HOME}/lib/${EXTERNAL_LIB_NAME}. This way, I can run my python scripts with just standard python installation on a machine. To be able to use the external lib, you'll have to include the lib directory to sys path like this:
import os
from sys import path as syspath
syspath.append(os.path.join(os.path.dirname(__file__), 'lib'))
P.S.: Since pygame has C/C++ files to be compiled, you'd have to use mingw instead. Refer to this answer for that: error: Unable to find vcvarsall.bat
EDIT: In case you're wondering how to build pygame from source, you'll need to run setup.py build. This will build the python library into 'build' folder of the package directory and there you'd see how it should be placed in Python's directory. You will face the compilation problem in Windows as I've mentioned before, but you can easily fix that.
EDIT 2: Download link to contents of 'lib' for PyGame:
Python 2.7: http://dl.dropbox.com/u/71422266/pygame27.7z
Python 3.2: http://dl.dropbox.com/u/71422266/pygame32.7z
If you're allowed to run stuff from a USB drive, one option would be to use Portable Python 2.7.3.2, which includes PyGame 1.9.1.

PyQt 4.7 - ImportError after installing on Windows

I've been trying to install PyQt 4.7 on Vista, but I am getting an ImportError when I try to do: from PyQt4 import QtCore, QtGui.
ImportError: DLL load failed: The specified module could not be found.
I've checked my System Path, and C:\Python31\Lib\site-packages\PyQt4\bin is on there.
I can't run any of the examples, but the Designer, Assistant and Linguist run fine.
I am using ActivePython 3.1, if that makes any difference. And I haven't had any previous version of PyQt installed.
Edit:
I've copied the QtCore4 and GtGui4 dlls to C:\Python31\Lib\site-packages\PyQt4. That fixes some of the examples, but I still can't use the example browser.
Are you sure there is a \bin directory for your version of PyQt?
I am running PyQt 4.4, and all my binaries are right in:
C:\Python31\Lib\site-packages\PyQt4
Which is what I have my path pointing too.
It sounds like PyQt4 was installed improperly... did you run this?
python setup.py install
There shouldn't be a bin there...
Just wanted to chime in that I had the same problem on a WinXP install of:
python 2.7
Qt 4.7.1 (10.05)
PyQt 4.8.1
I used the windows installer version of all 3 of those items.
Copying the contents of the C:\Python27\Lib\site-packages\PyQt4\bin folder up to the main PyQt folder (C:\Python27\Lib\site-packages\PyQt4) stopped the 'dll not found' errors that python was throwing.
Also chiming in. I installed both python 2.6 and PyQt 4.8.3 on a Windows 7 machine using the windows installers (I did NOT run 'python setup.py install').
I tried to run spyder (which requires PyQt 4.4 or greater) and failed because it couldn't find the PyQt .dlls. I copied all the .dlls from the \Lib\site-packages\PyQt4\bin folder to the \Lib\site-packages\PyQt4 folder, and spyder launches just fine.
PyQt installation also depends on the version of python installed on your platform.Python3.+ is incompatible with Python version < 3.x.
I was facing the same problem as I have Python 2.7 installed on my machine but I downloaded the latest binary which was PyQt-Py3.2-x86-gpl-4.9.exe. If you see here the binary has python version also mentioned in name after PyQt which is Py3.2. I uninstalled PyQt and installed PyQt-Py2.7-x86-gpl-4.9.exe which points to Python 2.7 and it fixed the problem.
Probably they could have mentioned the naming convention online or in some documentation to be more simpler.
I had the same problem. I got my program running from within Eclipse but when I tried running it directly from the command line I still got the same error.
I solved it by renaming the C:\Users\Me\AppData\Roaming\Python\Python27\site-packages\PyQt4 directory. (I'm guessing leftovers from a previous PyQt install)
I am using ActivePython.
I think there are at least two possible error conditions
1. ImportError: DLL load failed: The specified module could not be found.
then you have to check your PyQT version is comptible with your python. In other words, if you use python 3.3, then you can only use PyQT for python3.3 and python 3.3 will not work with PyQT for python3.4
This was the problem I met. I solved it with re-install it
2. Import Error: DLL load failed: %1 then something strange on a different encoding Win32.
then it would be a OS problem. If you use 32bit Python then you have to use 32bit PyQt, so do 64bit
Here's how I could fix those errors on Windows 7:
Get the PyQt4 wheel from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4.
Make sure that the version is exactly the same as your Python version (i.e. Python 3.3 doesn't work with PyQT for Python 3.4). Also make sure to download the 64bit version if you are on a 64bit machine and vice versa.
Extract the wheel with 7zip
Rename the PyQt4-4.11.4.data (or similar) directory to PyQt4
Go to PyQt4\purelib\PyQt4\ and move everything to the root PyQt4 folder. You can delete the purelib folder now
Copy the whole PyQt4 folder to your Python interpreters 'site-packages' folder (e.g. C:\Python34\Lib\site-packages)
Go to PyQt4\data\Lib\site-packages and move all the files to C:\Python34\Lib\site-packages\
In my case I needed MSVCP140.dll. I have solved this problem by dowloading Visual C++ Redistributable for Visual Studio 2015:
https://www.microsoft.com/en-us/download/details.aspx?id=48145
Got this solution from MSVCP140.dll missing
I am using Pyqt4 and Python 3.6 in Windows7.

Categories

Resources