27 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 \ ...
user avatar
  • 471
15 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 ...
user avatar
  • 402
14 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 ...
user avatar
  • 6,178
11 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 ...
user avatar
  • 6,178
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....
user avatar
  • 2,451
9 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 ...
user avatar
  • 1,198
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 ...
user avatar
  • 2,341
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 ...
user avatar
  • 2,895
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 ...
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 ...
user avatar
  • 66.5k
7 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 ...
user avatar
  • 39.6k
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 ...
user avatar
  • 2,017
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 ...
user avatar
  • 53.5k
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"...
user avatar
  • 55.8k
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.
user avatar
  • 6,161
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 ...
user avatar
  • 39.6k
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 ...
user avatar
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 ...
user avatar
5 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.
user avatar
  • 206
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.
user avatar
  • 851
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, ...
user avatar
  • 39.6k
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....
user avatar
  • 2,017
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 ...
user avatar
  • 191
5 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(...
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 ...
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 ...
user avatar
  • 53.5k
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 ...
user avatar
  • 15.5k
4 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....
user avatar
  • 156
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 ...
user avatar
  • 6,178
4 votes

How to fix Remote I/O Error Whilst Using i2c OLED

Since this used to work, I suspect that something is wrong with the wiring. My suggestion is that one or more of the wires has an intermittent fault. I would get a new set of wires, and replace the ...
user avatar
  • 1,524

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