28 votes
Accepted

Updating Python 3.7 to 3.8 on Raspberry Pi

Why? Just because it takes a while for distributions to integrate new versions. Here's what I did to install Python 3.8.5 on my rpi: sudo apt-get install -y build-essential tk-dev libncurses5-dev \ ...
Waxrat's user avatar
  • 546
16 votes
Accepted

Python script fails with 'ImportError' when run from rc.local

It's worth noting that rc.local is run by root, rather than the pi user which you are likely using at your terminal. It seems likely that your installation for the telepot module is installed only for ...
Aurora0001's user avatar
  • 6,278
16 votes
Accepted

Failed to create MMAL component b'vc.ril.camera': Out of memory

This error was resolved when I disconnected and reconnected my camera module. Somehow my camera module must have been wiggled loose when I was working with it and the Pi was not able to detect the ...
Justin's user avatar
  • 422
12 votes
Accepted

How fast can GPIO pins toggle?

There are some benchmarks from Henner Zeller's repository on GitHub which claimed that directly outputting data to the GPIO could achieve up to 65.8 MHz on a Raspberry Pi 3 (not B+, mind, but I ...
Aurora0001's user avatar
  • 6,278
12 votes
Accepted

Bluetooth library for Raspberry Pi

There are many options for using Python for Bluetooth Low Energy on Raspberry Pi. Maybe too many options and that is why there is maybe no one winner for all situations. BLE defines multiple roles ...
ukBaz's user avatar
  • 1,435
9 votes
Accepted

How does Raspbian know it's been installed in a Pi or Compute Module?

The command is: cat /proc/cpuinfo And the list over the different hardware is here: http://elinux.org/RPi_HardwareHistory#Board_Revision_History Table over hardware differences: https://www....
MatsK's user avatar
  • 2,726
9 votes

I want to run a Python 3 script on startup and in an endless loop on my Raspberry Pi

Your script is a typical use of a service. Usually a service is started once and then it is running in background until it is stopped by the service manager. The service manager can restart a script ...
Ingo's user avatar
  • 41.9k
8 votes
Accepted

Installing libraries via pip is taking forever. Raspberry pi 3b+

Building scipy from source takes about 1hr20. Pre-compiled wheels are available from piwheels.org, so you can install it from there without building yourself. Raspbian Stretch is pre-configured to ...
ben_nuttall's user avatar
  • 2,441
8 votes
Accepted

cron not executing python3

As is typical with crontab issues. The environment is not the same as your user or even a sudo/root shell , and env python3 may not return anything (env simply searches through Instead you should ...
crasic's user avatar
  • 2,983
7 votes
Accepted

How to connect MySQLdb in Python 3?

You have to install the MySQLdb package: sudo apt-get update then sudo apt-get install python3-dev libmysqlclient-dev This took a while and finally: sudo pip3 install mysqlclient now it should ...
bierschi's user avatar
  • 350
7 votes
Accepted

Only 1 thread starts when multi-threading in Python 3

Neither thread is actually started. Instead of threading.Thread(target = thread1()) you should use threading.Thread(target = thread1) At the moment you are calling a function which never returns ...
joan's user avatar
  • 70.5k
7 votes
Accepted

Open a Folder in the File Manager by a Python Script

For asynch : import os myfolder="/home/pi/Desktop" def onMyButtonClick(): os.system("pcmanfm \"%s\"" % myfolder) For asynch or ̶s̶y̶n̶c̶h̶ use python subprocess Popen : import subprocess ...
Ephemeral's user avatar
  • 2,147
6 votes
Accepted

Is it necessary to release Raspberry Pi Camera before rebooting? If so how do I do it?

There is NO NEED to do anything before a reboot. If you issue a sudo reboot command Linux will manage an orderly shutdown of the software. This is, however, a poor way of ensuring a reliable 24/7 ...
Milliways's user avatar
  • 58.6k
6 votes

How can I use OpenCV with Python 3 on a Raspberry Pi?

It says "Cannot open shared object". ImportError:libQTtest.so.4:cannot open shared object file:no such file or directory Yes, but it does not say this is because "the library isnt shared with it"...
goldilocks's user avatar
  • 58.5k
6 votes

GPIO LED Python

Thats because by using 'GPIO.setmode(GPIO.BCM)' you are specifying the BCM numbering convention. GPIO 18 is actual pin number 12.
CoderMike's user avatar
  • 6,827
6 votes

Failed building wheel for cffi on Model 3B+

ciffi depends on libffi, so I had to first install the libffi-dev package. Install it using: sudo apt install libffi-dev The package might be different if you are using some other distro.
H G Sur's user avatar
  • 216
6 votes
Accepted

Callback parameters to GPIO.add_event_detect?

I ran into the same issue. You can solve it without using another library. This is how you do it. def button_callback(button): print('Button {} pressed'.format(button)) GPIO.add_event_detect(...
othneildrew's user avatar
6 votes
Accepted

How to automatically rerun Python script if error occurs

You can run the script as service using systemd. Just create a Unit file with: rpi ~$ sudo systemctl --force --full edit myscript.service In the empty editor insert these statements, save them and ...
Ingo's user avatar
  • 41.9k
6 votes
Accepted

Error Installing TensorFlow on Rasperry Pi 3 B

Okay, I have solved my problem. I reinstalled Python 3.6. Then I used this command sudo apt-get install libhdf5-dev and then sudo pip install tensorflow and installed TensorFlow successfully! I ...
AnonyoZarif's user avatar
5 votes
Accepted

Pip3 install throwing error on raspberry pi 3 Raspbian-Jessie

From the error log, it seems to be an issue with the SSL protocol being used: File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1149, in _raise_ssl_error raise WantReadError() OpenSSL....
Anupam's user avatar
  • 166
5 votes

How fast can GPIO pins toggle?

If you want to synchronously transmit data at 50MHz frequency (that's how I read "pins to be toggled on the schedule of a ~50 mhz FPGA clock"), you will absolutely need to use the same clock source ...
Dmitry Grigoryev's user avatar
5 votes
Accepted

no module named 'speech_recognition'

Your tag says python3. If you are running your code in python3 you need to install speechrecognition with pip3.
T. M.'s user avatar
  • 871
5 votes
Accepted

how to install protobuf in raspberrypi3 b+ stretch?

I suggest to install protobuf in raspberrypi 3 b+ from the default repository. With: rpi ~$ apt list *protobuf* you will find some packages supporting protocol buffers. Just install what you want, ...
Ingo's user avatar
  • 41.9k
5 votes

Launch a GUI Tkinter program on boot

From Sparkfun website: The three methods covered in this tutorial are: rc.local - Likely the easiest and simplest way to get your program to run on boot. The downside is that tasks started with rc....
Ephemeral's user avatar
  • 2,147
5 votes
Accepted

Python3.7 with Numpy on Raspbian

The solution was surprisingly simple: Install an older Numpy version - I went with: sudo python3.7 -m pip install 'numpy>1.0, <1.15' --force-reinstall The installation took looong, but I'm ...
dtadres's user avatar
  • 191
5 votes
Accepted

5v/12v power source/submersible water pump/RPI/relay. What kind of combination is suitable?

12V pump will require 12V PSU. 20LPM is a pretty reasonable flow rate for a small pump so your pump PSU will need to have enough power to drive the pump - check the max current draw on startup (which ...
Bruce Heath's user avatar
5 votes
Accepted

Raspberry Pi Cluster for Computation

For a rough measurement, I generated a 2000 x 2000 matrix with random integer entries between 0 and 9, and timed computation of the determinant in SageMath (I did this twice, with similar results). On ...
Julian Rosen's user avatar
5 votes
Accepted

Can I use the Python Interpreter to list a modules' classes and methods, as well as descriptions?

This is not a Pi specific question, but all the normal python commands work (at least as well as in any python shell) e.g. import gpiozero help(gpiozero) dir(gpiozero) To document the Button class ...
Milliways's user avatar
  • 58.6k
4 votes
Accepted

Is there a problem with using deprecated os.popen?

According to docs.python.org os.popen() is stacked on top of subprocess.Popen() - at least for Python 3.x: This is implemented using subprocess.Popen; see that class’s documentation for more ...
Ghanima's user avatar
  • 15.8k
4 votes
Accepted

Raspberry pi no module named socket server

python is never Python 3 in Debian, even if you have installed Python 3. Python 3 will install as python3, and the python binary points to Python 2 (see PEP 394) instead. In Python 2, the ...
Aurora0001's user avatar
  • 6,278

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