PortAudio library not found by sounddevice - python

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

Related

Raspberry pi modulenotfounderror pymodbustcp

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 ...

isuue running rpi_ws281x(neopixels) using python on Rasberry pi 4

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

Error Python PlaySound No module named 'gi'

when I request using "playsound" library for Python to play the audio
file .mp3 it returns me the following error:
Code:
import playsound
playsound.playsound("test.mp3")
Error:
Traceback (most recent call last):
File "/home/enzoportela/PycharmProjects/SoftwareRover2018.2/SoftRover/I.A Rover(2018.2).py", line 25, in <module>
playsound.playsound("test.mp3")
File "/home/enzoportela/anaconda3/envs/SoftwareRover2018.2/lib/python3.6 /site-packages/playsound.py", line 91, in _playsoundNix
import gi
ModuleNotFoundError: No module named 'gi'
The most simple way is the vext approach.
pip install vext
pip install vext.gi
Reference:
How do I install python3-gi within virtualenv?
It seems like you are using an anaconda environment. I also faced this issue and fixed it by doing the following:
First, create a symlink to gi module in your system Python. For me, the command is as follows:
ln -s /usr/lib/python3/dist-packages/gi/ /home/USERNAME/miniconda3/lib/python3.7/site-packages/
Then, open the directory:
cd /home/USERNAME/miniconda3/lib/python3.7/site-packages/gi/
and run the following commands:
sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-37m-x86_64-linux-gnu.so
sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-37m-x86_64-linux-gnu.so
My system Python is 3.5 and miniconda Python is 3.7. Your versions may differ from mine, so take care of that in the commands above (-35m- and -37m-).
Method obtained from askubuntu

Trouble installing Adafruit's DHT11 Python library

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.

Trying to install J3DView

After entering the following in the command line:
sudo apt-get install python3 python3-dev python3-pip
sudo pip3 install cx_Freeze Cython PyOpenGL PyOpenGL_accelerate
sudo python3 setup.py install_exe
The last command gives me this error:
Could not import cx_Freeze. Building executable not possible.
Traceback (most recent call last):
File "setup.py", line 13, in <module>
from Cython.Build import cythonize
ImportError: No module named 'Cython'
Any ideas why?
I'm using Linux Mint 17.3 'Rosa' Cinnamon 64-bit.
[EDIT]
This problem was a complete mess and I still have no clue what happened before. I have given up trying to get Python to work, as I have found an application that does the same thing as the Python application I was trying to get working. It's such a pain.

Categories

Resources