Search code examples
pythonraspberry-pipython-3.7python-packaging

Python doesn't see machine package


I am developing a project on rpi 0 w and wanted to check out some GitHub code (https://github.com/adamjezek98/MPU6050-ESP8266-MicroPython) for MPU6050 sensor. There is a machine library required. However when I installed it isn't being seen by the Python (3.7).

(venv) pi@raspberrypi:~/Software $ pip freeze | grep machine
machine==0.0.1


(venv) pi@raspberrypi:~/Software $ python
Python 3.7.3 (default, Jul 25 2020, 13:03:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from machine import I2C, Pin
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'machine'
>>> 

I have no idea what is happening. As far as I am concerned I installed the right package:

(venv) pi@raspberrypi:~ $ pip install machine
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting machine
  Using cached machine-0.0.1-py2.py3-none-any.whl (4.2 kB)
Collecting pycrypto
  Downloading https://www.piwheels.org/simple/pycrypto/pycrypto-2.6.1-cp37-cp37m-linux_armv6l.whl (525 kB)
     |████████████████████████████████| 525 kB 309 kB/s 
Installing collected packages: pycrypto, machine
Successfully installed machine-0.0.1 pycrypto-2.6.1

Solution

  • You are installing the wrong package. The machine module in your snippet comes from micropython-machine: pip install micropython-machine.