installing python packages on raspberry pi pico - micropython

I'm trying to install pyalsaaudio on my Raspberry PI Pico board.
Firmware for my board I have build myself from micropython repo using documentation on how to do it from raspberry.
In documentation for micropython there is a section about Installing packages with mip but mip package is missing
>>> import mip
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'mip'
Another way I tryed to install this package was via Thonny package manager, but again, with no positive results.
error:
Failed to build pyalsaaudio
Error Command
'['C:\\Users\\<username>\\AppData\\Local\\pipkin\\cache\\workspaces\\fa71e45a1e41e660688341b77ee2813a\\Scripts\\python.exe', '-I', '-m', 'pip', '--no-color', '--disable-pip-version-check', '--trusted-host', '127.0.0.1', 'install', '--no-compile', '--use-pep517', '--upgrade-strategy', 'only-if-needed', 'pyalsaaudio', '--index-url', 'http://127.0.0.1:36628']' returned non-zero exit status 1.
Is there another way to install this package?
Or is there other package that will allow me to record audio from microphone?

Do you have a Pico or a Pico W? The Pico doesn't have a network interface of its own, so the standard firmware won't include mip. It looks as if mip was added to the Pico W port fairly recently, so you might need to check you have a recent build.
However, pyalsaaudio is a Python wrapper for the ALSA library which runs under the Linux operating system. The Pico boards (like most microcontroller boards used with MicroPython) don't have an operating system and can't have ALSA, so pyalsaaudio is no help here.
How is the audio source connected to your Pico? If it's on an analogue input (with suitable signal conditioning) you should be able to capture audio into memory with ADC.read_timed. If you need more help than that I would try asking in MicroPython's GitHub Discussions which has replaced the older forum.

Related

PyCUDA -- problems importing pycuda.driver

Windows 10
Python 3.8
CUDA 11.5
I've installed what I believe to be a matching pycuda from this file:
pycuda-2021.1+cuda115-cp38-cp38-win_amd64.whl
This simple example fails
import pycuda.driver as drv
drv.init()
print("Detected {} CUDA devices".format(drv.Device.count()))
With this error:
Traceback (most recent call last):
File "C:/University of Arizona/weeds/tests/cuda-summary.py", line 5, in <module>
import pycuda.driver as drv
File "C:\Users\evan\AppData\Local\Programs\Python\Python38\lib\site-packages\pycuda\driver.py", line 65, in <module>
from pycuda._driver import * # noqa
ImportError: DLL load failed while importing _driver: The specified procedure could not be found.
NVCC is in my path
Adding os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin')) has no effect
The script works just fine on my Jetson Nano
Any ideas on how to get past this? I've searched and tried several solutions.
It is quite strange, but updating the Nvidia display driver fixed the issue for me.
But in my case there was no issue on my PC with the same versions of Windows, Python, CUDA and PyCuda. The issue appeared on the different Windows 10 machine, when launching the exe, packaged by PyInstaller. So, updating the display driver was the fix for this machine.

Why can't I import and use machine.SoftI2C in Micropython v.1.13 on ESP32?

This relates to an ESP32 development module (from Amazon, similar to the DoIt module). I have Micropython v1.13 (Sep 2020) installed. According to the Micropython documentation
http://docs.micropython.org/en/latest/library/machine.I2C.html?highlight=i2c#machine.I2C
there is a class 'machine.SoftI2C(scl, sda, *, freq=400000, timeout=255)'. By my reckoning, I should be able to do:
'from machine import SoftI2C'
But it gives the error:
ImportError: 'can't import name SoftI2C'
SoftI2C is not listed when using 'help(machine)' (after 'import machine'), whereas I2C is. SoftI2C does not seem to exist.
This also applied to MicroPython v1.12
Any thoughts, anyone??
You're running version 1.13, but it looks like the SoftI2C name was introduced in commit c35deb2, which post-dates the 1.13 release.
It may be that the "latest" documentation tracks the head of the repository rather than the most current stable release. You can find the 1.13 docs here, and you'll note there is no notice of SoftI2C.
Try running a more recent build (I'm running one I downloaded today), which seems to be working fine).

Android Kernel Modules, Custom kernel

Was trying to make custom kernel. After making some changes build a kernel and installd on mediatek device gps, wifi stopped working
checked $ls -la /dev/ no devices found related to gps, wifi and bluetooth, extracted vendor.img and tried to insmod/modprobe the binary files of kernel still showing
insmod: failed to load bt_drv.ko: Exec format error
1|801:/sdcard/Download # modprobe bt_drv.ko
modprobe: /etc/modprobe.conf: No such file or directory
modprobe: /etc/modprobe.d: No such file or directory
modprobe: chdir '/lib/modules/4.4.97'
this errors and i've only vendor image(binary files of modules) not module code.
Since you rebuilt the kernel, you need to rebuilt the module as well, otherwise modules cannot be loaded due to signature mismatch. Since you do not have module source code, you can try to disable CONFIG_MODULE_SIG in kernel configuration to bypass module verification.

pySerial installed, but still getting ImportError

I am new to Python, so I have likely done something obviously wrong, though despite my best efforts I cannot figure out what.
I am running windows 7 64bit.
I only have Python 3.5 (32 bit) installed.
I updated pip to the latest version succesfully and used it to install pySerial. I am working in eclipse oxygen with PyDev installed. My run configuration does show the appropriate path (as far as I can tell):
run configuration in eclipse/PyDev
I have confirmed pySerial is installed by doing the following in python interpreter:
>>>help()
>>>modules
serial shows up in the list of modules.
also:
>>> import serial; print(serial.__file__)
C:\Python35\lib\site-packages\serial\__init__.py
Additionally, trying to use serial in the terminal works fine, as below:
>>> import serial
>>> s=serial.Serial("COM4")
>>> s
Serial<id=0x383b750, open=True>(port='COM4', baudrate=9600, bytesize=8, parity='N', stop
bits=1, timeout=None, xonxoff=False, rtscts=False, dsrdtr=False)
However, when I try to run the following code as a file:
import serial
print ("Test Script")
I get the following error:
Traceback (most recent call last):
File "C:\Users\H260643\Desktop\Projects\EclipseWorkspace\CMP_Thous_Hr\Base.py", line 1, in <module>
import serial
ImportError: No module named 'serial'
For what it's worth, the eclispe editor window has also flagged that line saying it is an "unresolved import: serial"
Right after posting this I realized that the install path for python/pySerial did not match what was in my eclispe/PyDev run configuration. I corrected my run configuration and all is well.

Error when executing Canopy's Pythonwin.exe (wincon32 module not found)

I'm sorry if my title doesn't make sense but that's the problem I'm having.
When executing a script at the command line, (or by double-clicking on it) using C:\pythonwin.exe SomeApp.pyw, I get a popup error box saying
ImportError: No module named wincon32. (Full error message at the bottom)
Just executing pythonwin.exe by itself with or without a script also has the same effect.
Google is amazingly bereft of any knowledge of wincon32. Trying to install wincon32 module with pip install wincon32 just says "Could not find a version that satisfies the requirement wincon32 (from version: ) No matching distribution found for wincon32"
pythonwin.exe is in the system's PATH.
Thanks for any help. Below is the full contents of the popup error box.
Title - Python Traceback
Traceback (most recent call last):
File "string", Line 1 in module
File "C:\Users\Me\Canopy(Python)\User\Lib\site-packages\pythonwin\pywin
\framework\startup.py", line 49, in _import_(moduleName)
File "C:\Users\Me\Canopy(Python)\User\Lib\site-packages\pythonwin\pywin
\framework\intpyapp.py", line 3, in import wincon32
ImportError: No module named wincon32
(I'm using Windows 10 x64)
Where did c:\Pythonwin.exe come from? It's not part of any Canopy installation that I've ever heard of. If you're trying to run Canopy Python, see https://support.enthought.com/entries/23646538-Make-Canopy-User-Python-be-your-default-Python