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
Related
so im using visual code,
have python 3.8 installed and i installed the pygame package from powershell,
yet when im writing pygame code it gives me the next error:
" ModuleNotFoundError: No module named 'pygame' "
tried everything for hours cant get it to work
help will be apriciated <3
images:
What you also can do is to download pygame to your folder and than run the command python setup.py. This should install everythin correctly. If you still have trouble using pygame you can use the files in src_py from the download:
import init #instead of pygame.init()
I hope I was able to help.
I'm running python 3.7.1 on my MacBook and it has been running perfectly until I tried importing pygame. I'm taking an intro to python class and we always just do from module import *. When I tried to do that same format with pygame I just got an error ModuleNotFoundError: No module named 'pygame'
What should I do about using pygame or should I just forget using pygame altogether
I'm new to python and the reason I'm trying to use pygame is that I'm making a game where the user controls a .gif or a spaceship and tries to avoid asteroids. All of my code is solid accept for the collision detection. Everyone seems to point me towards using pygame but i can't get that to work. Should I continue to use pygame and if so, how do i fix my problem? Should I drop pygame altogether and just try collision detection a different way; (if so, what other way?)
pygame is not bundled in standard python.
to install pygame in Mac, see
Mac installation from pygame.org
Also, from module import * is not a good practice if you're using more modules,
which will causes class name conflicts.
Easiest way to do it - forget 3.7.1 go on the Python website (linked) and download 3.6.7 ther when your setting up click add to PATH then you need to install pygame ( save it locally near where python is saved) then go on to terminal by going to finder and clicking applications and search terminal and type pip install pygame if there is anything you are confused about just ask (:
Path button
I am fairly new to python but am having issues importing certain packages within my code. I try to import pyperclip aswell as pygame. I've installed them both manually and I've tried importing them using import pygame and import pyperclip and I get
"no module named 'pyperclip'"
and the same thing for pygame. I've tried opening by putting just import pygame and saved it to run it in the interactive shell and I've also just tried typing it into the interactive shell.
I'm running linux mint 17.3 and python 2.7.6
Has anyone else had this issue?
Any help would be appreciated. Za
I had the same problem. I am also new to Python and programming. I tried about 100 things, but what worked for me was typing the following in the command shell:
pip install pyperclip
That was it. However, I was using Windows' command module, so. . . you know. But it's worth a shot!
This link might help, too (it has Linux instructions, etc): https://github.com/asweigart/pyperclip
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.
I was trying to get pygame on my mac to work. I got it running in terminal. But I run into issues when trying to use it with netbeans or trying to run the file. It gives me the error
from pygame.locals import *
ImportError: No module named locals
any help? Thanks!
If you still want to use netbeans, I think you should take a look at ActivePython
Activepython basically lets you install different pythons on your machine and be able to select between them (there's a lot more features I'm sure).
My advice would be to go to the console and type
>python
>>> from pygame.locals import *
If that works, ctrl-c out and do a python -v to find out the version.
Once you have the version, you can use activepython to select that version by running:
sudo pysel [version]. For instance for python2.7:
sudo pysel 2.7
This should switch the python over and your netbeans should (hopefully) work with it.