I have installed the files for ws2812 neopixels on raspberry pi 4b using :
curl -L http://coreelec.io/33 | bash
and ran the python strandtest.py
I am facing an import error
File "strandtest.py", line 9, in <module>
from rpi_ws281x import *
ImportError: No module named rpi_ws281x
Eventhough rpi_ws281x has been installed successfully.
While running the same code in the code editor, the module is imported properly and facing an other issue
>>> %Run strandtest.py
Can't open /dev/mem: Permission denied
Traceback (most recent call last):
File "/home/pi/rpi_ws281x/python/examples/strandtest.py", line 91, in <module>
strip.begin()
File "/home/pi/.local/lib/python3.9/site-packages/rpi_ws281x/rpi_ws281x.py", line 131, in begin
raise RuntimeError('ws2811_init failed with code {0} ({1})'.format(resp, str_resp))
RuntimeError: ws2811_init failed with code -5 (mmap() failed)
Initially, We have to install circuit python on your R_PI.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3-pip
sudo pip3 install --upgrade setuptools
follow the instructions in the link by adafruit:
https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi
and then run the example.
The adafruit website states, that you need root rights to access GPIO pins via rpi_ws281x. Try sudo python strandtest.py
Related
On my raspberry pi 4 I tried to code some basic stuff (like printing messages) to test out the pymodbustcp. I got the code from the pymodbustcp wiki so that shouldn't give the problem.
For some reason, it doesn't want to find the module of pymodbustcp and it gives this message below when I run the code. I think it has to do with pip but I am not sure
/home/pi/Desktop/Laadpunt/venv/bin/python /home/pi/Desktop/Laadpunt/main.py
Traceback (most recent call last):
File "/home/pi/Desktop/Laadpunt/main.py", line 7, in <module>
from pyModbusTCP.client import ModbusClient
ModuleNotFoundError: No module named 'pyModbusTCP'
Process finished with exit code 1
I installed both "sudo pip2 install pyModbusTCP" as "sudo pip3 install pyModbusTCP" in my console and that says:
pi#raspberrypi:~ $ sudo pip install pyModbusTCP
Traceback (most recent call last):
File "/usr/local/bin/pip", line 6, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli.main'
pi#raspberrypi:~ $
What could be the reason for the issue and how would I fix it?? If you need any info from commands tell me which ones.
sudo pip is not the way to go to install to your venv.
You should install to your venv specifically by doing
/home/pi/Desktop/Laadpunt/venv/bin/python -m pip install ...
I am trying to setup a PN532_NFC_HAT on a Raspberry Pi with nfcpy but I am having problems with modules.
What I have done so far:
I have installed nfcpy on my Raspberry Pi by simply doing this in the terminal.
$ pip install -U nfcpy
And I have verified the installation with this command
$ python -m nfc --search-tty
And so far it works, nfcpy can find my NFC Reader
Then I have cloned the examples from github
with the command
pi#raspberrypi: git clone https://github.com/nfcpy/nfcpy.git
and entered the examples-folder
pi#raspberrypi:~/nfcpy/examples $
What happens:
nfcpy has some example programs but when I try to run them they return various errors.
If I for an example run this command on one of the examples, Tagtool.py
python3 tagtool.py
I get this
Traceback (most recent call last):
File "tagtool.py", line 29, in <module>
import ndef
ModuleNotFoundError: No module named 'ndef'
Other examples return errors about not finding the module named nfc.
What am I doing wrong?
Please try below ↓
pip uninstall nfcpy
pip3 install nfcpy
or
sudo pip3 install nfcpy
I followed these instructions to install the Adafruit DHT11 library (https://github.com/adafruit/Adafruit_Python_DHT):
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo apt-get install build-essential python-dev
sudo python setup.py install
And I found the library installed under /home/pi (I'm working with a Raspberry Pi 3). The file I want to fun is in /home/pi/Desktop so I move the library into that directory. However, I still can't run my python file properly. This is the error I'm getting:
Traceback (most recent call last):
File "sensorRead.py", line 4, in <module>
import Adafruit_DHT
ImportError: No module named 'Adafruit_DHT'
How do I get rid of this error? And where should I move my file (or the library) so the library will work? Thank you.
I fixed it. I moved my file into Adafruit_Python_DHT/examples and ran it with the python sensorRead.py command. To be honest, I don't know why it works when I put it into examples, but it does.
I have been working with a python program which uses sounddevice module to play audio. The program works fine in my office pc (running Ubuntu 17.10), but not in my home pc (running Linux Mint 18.3). It generates the following error:
Traceback (most recent call last):
File "...path/to/my/code.py", line 11, in <module>
import sounddevice as sd
File "/home/arif/anaconda3/lib/python3.6/site-packages/sounddevice.py", line 64, in <module>
raise OSError('PortAudio library not found')
OSError: PortAudio library not found
How can I fix this problem?
I could fix this by installing the portaudio library.
sudo apt-get install libportaudio2
You may also try following if this doesn't help.
sudo apt-get install libasound-dev
I have installed Python 2.7.5 on Ubuntu 12.4 on a DELL LATITUDE E4300 64 bit and ran:
sudo pip install pyserial
nevertheless when running:
sudo python main.py
I receive the following error message:
Traceback (most recent call last):
File "main.py", line 4, in <module>
from mySerial import *
File "/home/oscar/ath10k/tools/sanity_test/src/mySerial.py", line 6, in <module>
import serial
ImportError: No module named serial
I looked on other posts but none of them helped me to solve this problem. I don't know what else to do I also ran:
sudo -H pip install pyserial
and
sudo pip install pyserial --upgrade
Any help will be greatly appreciated.
Kind regards.
Oscar.
On my ubuntu 14.4 with python 2.7 as default, I installed pyserial for python3 (which my IDE is using actually) with the help of following command:
sudo apt-get install python3-serial
Your script name is exactly like module name, change mySerial.py to something else.
I solved this by installing pyserial from source code instead than doing it with pip.
I do not know why it works this way and when using pip it prints error messages.