Questions tagged [python]

Python is a general-purpose, dynamically typed, object-oriented high-level programming language. Interpreters for versions 3.x and 2.x come installed on the Raspberry Pi's most popular operating system distributions.

Filter by
Sorted by
Tagged with
8
votes
3answers
33k views

ImportError: No module named RPi

I am trying to run a package on my Raspberry Pi: At the terminal, I typed in “sudo apt-get install picap” followed by enter. I get it installed but cannot execute "picap-setup" – instead an error ...
8
votes
1answer
15k views

How to use the water flow sensor with raspberry?

I'm trying to use this water flow sensor with raspberry: https://www.adafruit.com/products/828 I'm using this python code to read the pulses: #!/usr/bin/env python import RPi.GPIO as GPIO import ...
8
votes
3answers
622 views

How does init get to know about power events?

I have a Pi Model B Rev 2.0 (I think) and I intend to use it for a Home Automation system. As I have a prepayment meter on my electricity supply I occasionally run out of electrons to go around my ...
8
votes
2answers
17k views

What's the right way to run a python script as a daemon (service) in raspbian (or debian)?

I'd like to use my Pi as a home thermostat, with the control loop running in a python script. I want to run it as a daemon on raspbian (debian) at startup. There's an example bash script in /etc/init....
8
votes
2answers
20k views

Streaming Raspberry Pi camera to HTML webpage using picamera and Flask

I am trying to use the picamera API and Flask to implement a pure Python (live) stream of the continuous JPEG from the Raspberry Pi camera module to display it using a HTML template but I keep getting ...
8
votes
1answer
1k views

Raspberry Pi Camera - When is it ready for next frame

When using apis like the C++ or raspicam api, you poll the camera with a grab(), or similar, method. When a frame is ready, the method returns. Is there a way of checking if the camera is ready ...
8
votes
1answer
48k views

Using python with bluetooth to communicate

I'm trying to write a simple program to communicate between the RPi and a bluetooth cellphone. I went with this tutorial: Bluetooth Python tutorial for RPi and was able to connect to the phone and ...
8
votes
2answers
10k views

I want to switch between versions 2 & 3 of Python. Both are installed

If I double click on a .py file it opens "IDLE" (is there another way to open "IDLE"?), but the default python version is 2 when I select "run". I want to PERMANENTLY change the default version to 3 ...
7
votes
6answers
10k views

Testing Raspberry Pi scripts on a PC

I'm writing a Raspberry Pi program, to run stuff, take inputs from sensors, save in database and synchronise to a server. Is there a way to test it on the PC before deploying it to the Raspberry Pi? ...
7
votes
4answers
26k views

Ping a website and have an output turn on if online/offline?

I am new to python and programming the Pi, my aim is to make it ping a server such as a gaming server or website and tell me if it is online or offline. So far I have looked everywhere but nobody ...
7
votes
1answer
464 views

Bit waveform clarification

I have been trying to learn more about bit transmission through the uart, and I have the following code in python to transmit information: import serial ser = serial.Serial( port='/dev/ttyAMA0',...
7
votes
2answers
979 views

Issue with push button on raspberry PI

I'm currently working with Raspberry Pi. I have implemented push button(switch) program using python. But, When I press the switch, then if condition is true and data stored but when I release the ...
7
votes
1answer
7k views

Using a class function as callback

I want to set a callback function to run when an event occurs in a GPIO. I'm designing a class and I want to have the callback method inside it too. Here's an excerpt of the code: import RPi.GPIO as ...
7
votes
1answer
17k views

How do capture audio using Python?

More particularly: How can I use python with ALSA to capture audio input? I'm thinking about doing an oled-based spectrum analyzer for Pi-based audioplayer. One part of the solution is to read the ...
7
votes
1answer
1k views

Raspberry Python Libraries

I am currently working with a Raspberry Pi (Model B+) and have some experience with Arduino (and it's derivates). Now, there are three Libs for GPIO access with Python for the Pi: WiringPi (...
6
votes
4answers
26k views

Are there any Python IDEs for Raspberry Pi 3 with step-through capability?

I've used PyCharm by Jetbrains on Windows/full blown Linux and I like the ability to step through code. However, due to the processor of the Raspberry Pi 3, it doesn't run very quickly. Can anyone ...
6
votes
3answers
1k views

GPIO status after python code is closed

I intend to write a python script to change the status of GPIO pins. The code will receive arguments through sys.argv, change the state of some GPIO pins, and close afterward. My question is: Do the ...
6
votes
2answers
10k views

Pi camera v2 - fast, full sensor capture mode with downsampling

I've a Pi camera v2 which I'm planning to use with an RPi3 for a computer vision project. I need to capture full sensor images from the camera - no cropping. The resolution actually used by the ...
6
votes
2answers
29k views

How to download and install Python 3.5 in Raspbian

Tried to use sudo apt-get install python3.5 and it's telling me that it can't find it. Have tried updating. Not sure what else to do.
6
votes
2answers
9k views

Can I run TensorFlow on the Raspberry Pi?

I wan't to know if TensorFlow (http://tensorflow.org/) can be used on the Raspberry Pi both the Python API and the C++?
6
votes
5answers
19k views

How to blink LEDs on/off continually, while continuing execution of a script?

I've connected red and green leds via GPIO and I can successfully switch them on/off using RPi.GPIO - now I'd like to: start an led blinking on/off every 1 second have the script continue its ...
6
votes
4answers
29k views

How does python GPIO bouncetime parameter work?

I have a simple Python script that is observing two GPIO pins, I've set the bouncetime parameter to 500ms, but I get multiple (almost always 2) calls to my callback, usually 3 or 4 ms apart. This is ...
6
votes
3answers
10k views

YOLO or SSD on raspberry pi

I've run yolov2 on my Raspberry Pi 3 but I got 1 frame each 13s (which is pretty bad for live object detection). I've also tried an SSD but the results were terrible too. Is there anything I could do ...
6
votes
4answers
1k views

Temporary blocking all network access for a limited time while a CPU sensitive task is running

I'm trying to find a way to block all internet access (and local network access) to a Raspberry Pi 2 for a limited time while an important task is running. The problem is, my Pi is doing a video ...
6
votes
2answers
6k views

Implement a GPIO function with a callback calling a asyncio method

I am testing a sensor attached to the GPIO in raspberry using python 3.5. The idea is something similar to this link. My code is: gpio.add_event_detect(4, gpio.RISING, callback=lambda x: self....
6
votes
2answers
2k views

What's the RPi camera board called (internally)?

I connected a Rpi-camera board to the camera socket on my RPi (not a usb webcam). I have been searching the internet on how to call the camera in Python. The camera works (raspistill and raspivid both ...
6
votes
1answer
7k views

Pygame from console with PiTFT

I wrote a simple script that uses pygame to display the information. However, I found that it won't display on screen when I call it from terminal through SSH. I found this guide/solution on adafruit, ...
6
votes
1answer
11k views

Which Miniconda version should I use with Raspberry Pi 3?

Hi I am trying to install Miniconda2 4.0.5-Linux-x86.sh on my Raspberry Pi 3. Everything starts fine till it installs:setuptools-20.3-py27_0, line 288 binary cannot be excecuted. Is there already any ...
6
votes
3answers
12k views

Adafruit I2C Library Problem?

I'm having trouble compiling the python from an example in the library. https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/blob/master/Adafruit_ADS1x15/ads1x15_ex_singleended.py I ...
6
votes
2answers
13k views

Sending Commands from PC to Raspberry Pi via USB

I am currently doing a project with the Raspberry Pi as a controller connected to a PC via USB and using the Pi to send commands to other devices connected via GPIO pins. Simplified version: ...
6
votes
1answer
4k views

Can I control Minecraft Pi Edition over SSH from another computer?

I recently downloaded the Minecraft Pi edition for my Raspberry Pi. The main feature of the Minecraft Pi edition is the ability to interactively edit the landscape using Python. One would expect that ...
6
votes
2answers
7k views

Flow meter Raspberry circuit and problem receiving pulses

I am trying to connect a flow meter YF-S201 to Raspberry Pi B+. It has three wires --> Red -> 5V --> Blac -> Ground --> Yellow -> Signal I have a doubt with the cicuit, The flow meter works in 5V ...
6
votes
1answer
4k views

RPIO does not work on Python 3, only in Python 2.7

I've installed RPIO library to my RPI following these instructions: $ sudo apt-get install python-setuptools $ sudo easy_install -U RPIO I'm trying to run this code (test.py): from RPIO import PWM ...
6
votes
4answers
26k views

Sending live data readings from Raspberry Pi to laptop

I have a simple Python code that takes readings from a temperature sensor. I wish to send these readings (each time one is recorded in the code's while loop) to my laptop so the values can be used in ...
6
votes
3answers
3k views

Is there a way to make a regular GPIO pin into a Tx UART pin?

I'm working on a project that is going to need two different UART interfaces. Is there a way to make a regular GPIO pin into a Tx UART pin, I don't need an Rx pin too. Is there a software solution ...
6
votes
1answer
38k views

Real time audio input/output in Python with PyAudio

I am trying to get my Raspberry Pi to read some audio input through a basic USB souncard and play it back in real time for 10 seconds, and then print the output with Matplotlib after it's finished. I ...
6
votes
3answers
22k views

Serial Port on Raspberry Pi 3 ttys0

I have a Raspberry Pi B and a Raspberry Pi 3. I am trying to get the Raspberry Pi 3's serial port working. I have put a jumper across pins 8 and 10 to check the serial port is working. I've executed ...
6
votes
1answer
2k views

Installing pymedia

I've got a project in mind and I would like to use the spectrum analyzer of pymedia to get frequency data from audio while it's playing. Has anyone managed to install it? I've tried and failed. I've ...
6
votes
1answer
5k views

Changing RFID key for RFID-RC522

I have been playing around with my RPi2B (with Jessie), an adafruit breakout board and a RFID-RC522. I followed a guide to make it work, and it works like a charm Guide for adding RFID-RC522 to RPi2B ...
6
votes
1answer
579 views

My PI crashes and freezes when playing music from Spotify

I've programmed a small spotify application on my RPi that freezes quite often. I'm wondering if anyone here has any experience using pyspotify and managed to create a stable application using this ...
6
votes
2answers
2k views

Problem with Python Games

Having eagerly ripped open my newly arrived toy, I've just installed the Raspbian Wheezy image & am impressed that it really does just boot and appears to work - however, the Python Games that ...
6
votes
2answers
8k views

GPIO pins are always HIGH

I recently have started delving into using the GPIO on my raspberry pi and when I got to the input section of adafruit's tutorials I noticed something wrong. For some reason when I execute the python ...
5
votes
4answers
7k views

Do we need multiple versions of Python?

I am new to Linux and going through my installed folder I can see there are four different Python folders in the directory list. python python2.7 python3 python3.2 Do we need all the four versions ...
5
votes
3answers
7k views

How to Run pigpiod on boot

In order to use pigpio Module in Python (remote GPIO for Raspberry Pi ), pigpiod has to be loaded to memory on each RPi. what is the right way to to it ? during Ubuntu's boot or a part of Python's ...
5
votes
3answers
4k views

Display IP Address on Character Based LCD

I need to know the IP address of my raspberry pi. I need to do this with a Character LCD display. So here's what I have done so far. I can display text on a HD44780 based 16x2 LCD connected to my ...
5
votes
1answer
3k views

BlasNotFoundError when installing Scipy through pip

I'm trying to install Scipy in a virtual env through pip and I'm getting an error that says numpy.distutils.system_info.BlasNotFoundError I've never run into this before and I installed numpy from pip,...
5
votes
3answers
28k views

Python serial permission issue

I'm trying to connect my Arduino to my RPi through python and PySerial, and I'm using the following code: import serial ser = serial.Serial('/dev/serial/ttyACM0', 9600) and I was getting an issue ...
5
votes
2answers
8k views

Upgrade from Python 2.7 to 3.3,x

How do I uninstall Python 2.7 and install the latest Python 3.3.x? Tried using "upgrade" but it didn't solve my problem.
5
votes
3answers
4k views

OTA Update of Multiple Raspberry Pi's

I have 4 Raspberry Pi compute modules, running at different locations and I would like to run a script from the server that would connect and update the pi's with the latest version of the file found ...
5
votes
2answers
2k views

Raspberry Pi to Arduino (Leonardo) avoiding latency

I'm using a Python script via (TkInter) on the Raspberry Pi to capture mouse movement and events. My goal is to send this data, in real time, to another connected Arduino device(Leonardo). My first ...