I am running the following blink program on my raspberry pi pico. I am using circuit python.
from machine import Pin
import time
led = Pin(13, Pin.OUT)
while True:
led(1)
time.sleep(1)
led(0)
time.sleep(1)
When I run it though it gives this error:
Traceback (most recent call last):
File "code.py", line 1, in <module>
ImportError: no module named 'machine'
I have tried to find if I need to download a library file or any thing about the machine module, but I have found nothing. If you know why it can't find the machine module that would be greatly appreciated.
Your code is for micropython. Circuitpython is different. See here https://learn.adafruit.com/circuitpython-essentials/circuitpython-digital-in-out
from digitalio import DigitalInOut, Direction, Pull
led = DigitalInOut(board.LED)
I was having same issue and a search found this thread.
I changed the Interpreter setting in Thonny (under options) from Local Python 3, to MicroPython (Raspberry Pi Pico)
I think you are using the incorrect uf2 file as the official (stable) version is not out as of writing this.
In order to check this, type the following in MircoPython's command line:
import sys
sys.implementation
(name='micropython', version=(1, 19, 1), _machine='Raspberry Pi Pico with RP2040', _mpy=4102)
If the response shows "Pico" and not "Pico W" then copy the latest version from here and copy it onto your Pico W (in USB mode)
Related
I'm trying to read pulse with the 'countio' library from CircuitPython. When I'm importing the library, it says:
Traceback (most recent call last):
File "fanfan.py", line 2, in
import countio
ModuleNotFoundError: No module named 'countio'
Here is the codes I used:
import board
import countio
# Count rising edges only.
pin_counter = countio.Counter(board.D1, edge=countio.Edge.RISE)
# Reset the count after 100 counts.
while True:
if pin_counter.count >= 100:
pin_counter.reset()
print(pin_counter.count)
I tried
pip3 install countio
but it's not working.
Is there any way to install the countio library on Raspberry pi 4B?
Of course it fails. Because it simply does NOT exist: click me
A very simpl look up on the homepage of CircuitPython revails the actual libraries:
So, to answer your question: No, there is no way to install countio library on any platform, because it does not exist.
I am trying to stream video in web using Raspi cam. I am using a code from internet but it has an error and it shows this,
Traceback (most recent call last):
File "picam.py", line 8, in <module>
import socketserver
ImportError: No module named socketserver
I don't know what to do. Help me please? THANKYOUUUU!
The code I'm using is in http://picamera.readthedocs.io/en/latest/recipes2.html#web-streaming
(4.10 WEB STREAMING)
You are most probably using Python2 which has SocketServer.
I'll recommend that you use Python3 which has socketserver.
Reference -> No Module Named ServerSocket
I have a python3.2 script running from rc.local at startup on a raspberry pi - Raspbian OS, it imports a file called inouts.py module that i made and lives in the same directory, ive updated the sys.path.append(...)
The script worked fine for weeks. Today I had to unplug the rpi without shutting down.
After rebooting the script fails to open and gives the error:
EOFError: EOF read where not expected
The inouts.py is definitely the module causing the error as I have it on its own line.
If I change the name from inouts.py to inouts2.py the script works.
If I run it as python2 it also works.
Can anybody point me in the right direction on what might be causing this filename to cause this error?
Traceback (most recent call last):
File "rf2.py", line 3, in <module>
import inouts
EOFError: EOF read where not expected
I solved this problem myself today by deleting all of the *.pyc files in the __pycache__ subdirectory.
I was looking a way to prove my USB-SERIAL port and I found this code:
http://www.digitalmihailo.com/usb-programming-with-python-on-linux-pyusb-version/, but I have a problem because when I run this program, then show me up this message:
Traceback (most recent call last):
File "namefile.py", line 122 in <module>
main()
File "namefile.py", line 64, in main
raise ValueError('Device not found')
ValueError: Device not found
I already install the PyUSB library, but the result does not change. Someone can help me with this little problem.
Thank you much in advance.
If you are running your example in Linux you need to load the ACMtty module so you system makes a Serial USB device available for your user space.
As root and only if you have cdc-acm module compiled for your current kernel:
modprobe cdc-acm
Once this module is loaded and your device connected you should find a device named following this pattern: /dev/ttyACM*
You may have already installed the right user space tools and libraries but you also need to install the device.
Now it's been like 3 days and I still don't manage. Maybe someone can help.
I want to send a control command to a midi device, via python, on a mac. Everywhere I see, the happy answer is to use pygame, but truth is that the pygame version on the mac lacks that functionality.
When I try run this two lines :
from pygame import midi
midi.init()
I get the following error:
Traceback (most recent call last):
File "midi_send.py", line 9, in <module>
midi.init()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pygame/midi.py", line 71, in init
import pygame.pypm
ImportError: No module named pypm
I've looked and looked and all I find is dead ends.
Has anyone actually tried using pygame to write to a midiport, on a mac? is there an alternative that doesn't include getting stuck in some gcc compile error something replace line N of somemidi.o file somewhere in /etc/whatever/whatever?
Sorry for being frustrated...
You could try using the rtmidi-python library (or older and slightly different pyrtmidi) - both based on rtmidi which provides for straightforward sending of MIDI Control and Notes:
import rtmidi_python as rtmidi
midi_out = rtmidi.MidiOut()
midi_out.open_port(0)
midi_out.send_message([0x90, 48, 100]) # Note on
midi_out.send_message([0x80, 48, 100]) # Note off