Hot answers tagged

14

An easy way to find the package providing a given file is apt-file; you can also do much the same thing online from here. First you need to install apt-file: > sudo apt install apt-file After that: > apt-file search "sdl-config" emscripten: /usr/share/emscripten/system/bin/sdl-config libsdl1.2-dev: /usr/bin/sdl-config libsdl1.2-dev: /usr/share/man/...


5

What do you mean by "hang"? I had problems with my headless pi that every 2-3 days I could not connect to it. It was working ok but I could not ping nor ssh to it. Turned out to be a problem with the power management in the wifi dongle: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=51543&p=397663 Once I turned of the power management features as ...


3

Here's a writeup for the hack we came up with in the comment stream: Most fortunately, we're able to take advantage of the limited scope of this request: I don't care that sound doesn't work on pygame. The application works perfectly just this annoying 6 line error message shows. I just want to get rid of the messages We don't know why exactly ALSA is ...


3

some of the errors here, and I hope someone can help explain why these errors occur That's literally just the tip of an iceberg. By "literally", I mean system log messages are classified into 8 levels of priority (see man logger or man 3 syslog), and, depending on configuration (see /etc/rsyslog.conf; it might also just be syslog.conf), the highest one or ...


2

I had the same problems with Stretch (Desktop) and pi3. My solution: Not to use pygame for the touch. Take this instead: python-multitouch Works very good with very less changes in the code.


2

The problem wasn't anything to do with Python, but rather that my pi user settings were different from my root user settings, so that the former went through the chosen USB audio device, but I couldn't get the latter to change from default settings. I only noticed this via Python because I would run my python script using sudo. The non-accepted answer from ...


2

As pygame rely on SDL system, we have to define the audio driver for SDL. This can be done with environnement variables. You can define it in your python script, but this must be done before you init pygame. os.putenv('SDL_AUDIODRIVER', 'alsa') os.putenv('SDL_AUDIODEV', '/dev/audio') You may also define the env.var. SDL_AUDIODEV in the same manner, if you ...


2

I finally made this work. Check your alsa.conf and .asoundrc file, only one of them needs to be configured with your audio setup. I setup my audio in both files which caused the confusion, once I restored alsa.conf to default, the problem is gone.


2

Try installing Wheezy instead of Jessie: I had the same problem on the 2.8" capacitive TFT after upgrading Raspbian to Jessie; but it runs ok with latest Wheezy release.


2

Graphics output on the Pi is usually displayed via the X Window System (aka X11, or simply X). You can confirm this by plugging a compatible TV/monitor into the Pi's HDMI-out. If you want to view from your laptop some kind of VNC software is the easiest route. (RealVNC is installed on recent Pi images by default.)


2

Your error (and the documentation) says it all: pygame.mixer has no attribute my_Sound. It does, however, have an attribute named Sound, which you have in your posted code. However, you error line shows you using my_Sound instead of Sound. Moreover, your pygame.init should be a function call, that means it needs (). So it should be: pygame.init() All in ...


1

Turns out an audio jack has to be connected when the python script is running in order for the USB sound card to be working. Strange, but works for what I'm trying to do. When configured to use the internal 3.5 mm minijack port this is not needed.


1

I think you mean mice 😉. You can connect 2 - I do this occasionally, but you will only have 1 cursor.


1

To answer my own Question at least to a small extend: VLC seems to offer a something similar to pygame but with the advantage that (to my knowledge) no screen is needed and it plays pretty much every data Format. Here a quick link: https://linuxconfig.org/how-to-play-audio-with-vlc-in-python As for the code, Iam still greatful for every advice, especially ...


1

This is what @archdata found for his solution and added it to his question. I have moved it from there into this answer to respect the sites policy for answering. @archdata wrote: This is now working. I have updated the code above to match what works for my project. The trick to running it is found here How do I let an SDL app (not running as root) use the ...


1

The PyGame library treats keypad keys different from normal keys. For instance, the normal enter key is defined as pygame.K_RETURN while the keypad enter key is pygame.K_KP_ENTER, so you should replace K_RETURN with K_KP_ENTER in your code. You can find a full list of the key codes here.


1

When you run your script "manually", you are running the script as the username under which you're logged in. When you "auto-start" the script with cron you are invoking the script as a different user. Best guess: It seems to me that your problem may be that your "manual" user has access permission to the fonts, but your "cron" user does not. Alternatively,...


1

This worked for me. sudo apt-get install python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev Taken from https://stackoverflow.com/questions/7652385/where-can-i-find-and-install-the-dependencies-for-pygame


1

Pygame is not a framework where button, frame and windows are already defined. It is a more low level access to the framebuffer. To use pygame with the framebuffer you should write something into it. Basically, your program only declares the screen (which is initially black) and... do nothing else. You should use blit to write/place texts and images to the ...


1

Well... even if your script has no mention of any sound stuff, pygame could very well include sound-related stuff inside and that's why you are seeing those messages. If you want to avoid those messages from showing up on the terminal, you can just redirect output so that you don't get it at all: python my-script.py &> /dev/null and voila! No output on ...


1

I found this thread. I tested the solution between two of my personal computers, both running Linux. To find out the value of $DISPLAY, use a keyboard hooked directly to the pi. Then in the terminal type echo $DISPLAY The value will probably be :0.0 Then once you ssh into the pi, type export DISPLAY=:0.0 (but replace the :0.0 with whatever value the echo $...


1

I must confess that I know nothing about image processing from the Pi camera and I've only played around a little bit with Python. Yet some things look suspicious about your code. You seem to be creating a socket connection, sending one image (still frame) down the pipe, closing the socket, then repeat. You don't want to be doing it this way. Too much ...


1

Pygame can be used to play music. See Making Games With Pygame (.pdf) For a simple example: # libraries import pygame import time # instantiate pygame pygame.init() # select track pygame.mixer.music.load("./directory/01 Track name.mp3") # play music (on loop) pygame.mixer.music.play(-1, 0.0) # wait time.sleep(10) # stop music pygame.mixer.music.stop()...


1

This is technically not an answer, but more of a work around. I have completely given up on SimpleCV. I don't know if there is an error in SimpleCV, pygame, or if it is just all over my head. I have found that if I use pygame to take the picture and reinitialize it every minute, I never get a segmentation fault. import cv2 import numpy as np import ...


1

Ok, I'm not sure if this is the proper way to fix this, but I found that the script ended before the audio has a chance to play. So to fix that I added: time.sleep(hello.get_length()) to the script and it works fine now. So the full script looks like so: #!/usr/bin/python import time import pygame import os pygame_init() sound = pygame.mixer.Sound(os....


1

Thank you @goldilocks for your comments on this, to clarify what I was doing: the pi was booting to the cli and here there was a script in init.d to run the python/pygame script. I wasn't using the X server at all. From your comments I've looked into using X server without the windows manager (which I had no idea about), using these sources: This Xclients ...


1

I had a similar problem with pygame. However, I found that my issue was completely unrelated. This may be the case for you as well. The problem is likely not a product of an issue with the pygame.midi, so much as it lies with the fact that your raspberry pi may be configured to forward its audio output to the HDMI cable connection. I found that a fix can ...


1

I solved it by running sudo apt-get install timidity and then changing my outport port from 0 to 3.


1

You will probably want to have a "calibration" procedure that directs the user to manipulate all the joystick controls that are not simple "up"-"down" buttons. You will need to ask the user to take each control to the extremes that each one has and have the code notice what values are detected at those extremes - on some systems (old PC analogue joysticks ...


1

Have a look at the following. #!/usr/bin/env python import time import pigpio STOPGO=18 green=1 red=2 state_color1=None state_color2=None def stopgo_func(gpio, level, tick): global state_color1, state_color2 if level == 0: state_color1 = green elif level == 1: state_color2 = red pi = pigpio.pi() # Connect to Pi. cb = pi.callback(...


Only top voted, non community-wiki answers of a minimum length are eligible