Python3 REPL vs python "filename".py

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
JimGig
 
Posts: 11
Joined: Fri Jun 18, 2021 5:39 pm

Python3 REPL vs python "filename".py

Post by JimGig »

I'm just learning python.
So far, I have been using python3 REPL. I wrote a small script that runs fine within REPL.
Within a directory, I ran: pi@raspberrypi:~/Projects/RCTruck $ sudo pip3 install adafruit-circuitpython-motorkit.
Installs successfully.
Within the same directory, I put the same code into a .py file and run the file using python "filename".py, I get error messages saying:

pi@raspberrypi:~/Projects/RCTruck $ python RCTruck01.py
Traceback (most recent call last):
File "RCTruck01.py", line 17, in <module>
from adafruit_motorkit import MotorKit
ImportError: No module named adafruit_motorkit

See attcehd for sample code.

How do I resolve this error message?
Attachments
2348_17Y_stepper.txt
copy of code
(1.02 KiB) Downloaded 2 times

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: Python3 REPL vs python "filename".py

Post by tannewt »

What does `python --version` show? My guess is that `python` is python 2 for you. Try `python3 RCTruck01.py`.

User avatar
JimGig
 
Posts: 11
Joined: Fri Jun 18, 2021 5:39 pm

Re: Python3 REPL vs python "filename".py

Post by JimGig »

That works!
Thank you.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”