Toni
Toni

Reputation: 25

AS5600 sensor raspberry pi4 / ModuleNotFoundError: No module named 'machine'

I am trying to read the AS5600 sensor with my raspberry pi 4. I tried this script (https://github.com/sgall17a/AS5600) but unfortunately I get an error every time. Can someone help me to read the AS5600 on the Raspberry pi4 with python?

Error:

pi@raspberrypi:~/Desktop/software $ python3 test.py
Traceback (most recent call last):
  File "test.py", line 2, in <module>
    from as5600 import *
  File "/home/pi/Desktop/software/as5600.py", line 1, in <module>
    from machine import I2C,Pin
ModuleNotFoundError: No module named 'machine'

I tried the following but still ModuleNotFoundError: No module named 'machine':

pi@raspberrypi:~ $ pip install machine
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting machine
  Using cached https://files.pythonhosted.org/packages/c0/ce/0c62600971471aabe55865c7100a886f3c2cad767e3a0af2dff717d08e68/machine-0.0.1-py2.py3-none-any.whl
Requirement already satisfied: pycrypto in /usr/lib/python2.7/dist-packages (from machine) (2.6.1)
Installing collected packages: machine
Successfully installed machine-0.0.1

After some googling I found out that I probably need "micropython-machine" so I tried it and got the next error:

pi@raspberrypi:~ $ pip install micropython-machine
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting micropython-machine
  Using cached https://files.pythonhosted.org/packages/e1/31/a3282942b3e96881393db406130735913c647f0fc9e07a0d60d7b546b06b/micropython-machine-0.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    IOError: [Errno 2] No such file or directory: '/tmp/pip-install-28u1A1/micropython-machine/setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-28u1A1/micropython-machine/

Upvotes: 0

Views: 659

Answers (1)

larsks
larsks

Reputation: 311740

It looks like you are trying to run micropython code with regular Python. From the README in the linked repository:

This is a Micropython library for reading an AS5600 using I2C. It was developed on a Seeedstudio board and Raspberry Pi Pico. It should work with other MCU's running Micropython but I2C setup may differ on on other boards. It may work on circuit python but I have not tested this.

You cannot run Micropython code with regular Python. This project is meant to run on a microcontroller (like the Pico).

You could port this code to Python; that would require replacing the use of the machine module with appropriate alternatives for interacting with the GPIO features of your raspberry pi. How to do that is probably outside the scope of Stack Overflow.

Upvotes: 0

Related Questions