0

I used the following tutorial (https://iotdesignpro.com/projects/raspberry-pi-stepper-motor-control-through-a-webpage-using-flask) to control my NEMA17 stepper motor using a A4988 stepper driver. As soon as I run the stepper.py program I get that error:

Traceback (most recent call last): File "stepper.py", line 4, in from RpiMotorLib import RpiMotorLib ImportError: No module named RpiMotorLib

I have pip 20.2.4 installed.

I'm new to coding so any help is welcome!

from time import sleep
import RPi.GPIO as GPIO
from RpiMotorLib import RpiMotorLib

#define GPIO pins
GPIO_pins = (14, 15, 18) # Microstep Resolution MS1-MS3 -> GPIO Pin
direction= 20       # Direction -> GPIO Pin
step = 21      # Step -> GPIO Pin

# Declare an named instance of class pass GPIO pins numbers
mymotortest = RpiMotorLib.A4988Nema(direction, step, GPIO_pins, "A4988")

app = Flask(__name__)

#HTML Code 

TPL = '''
<html>
     <img src="https://iotdesignpro.com/sites/default/files/Iot%20Design%20Pro%20Logo_0.png" alt="">
    <head><title>Web Page Controlled Stepper</title></head>
    <body>
    <h2> Web Page to Control Stepper</h2>
        <form method="POST" action="test">
            <h5> Use the slider to rotate Stepper Clockwise & Counter-Clockwise  </h5>
            <p>Slider   <input type="range" min="1" max="20" name="slider" /> </p>
            <input type="submit" value="submit" />
        </form>
    </body>
</html>


'''
 
@app.route("/")
def home():

    return render_template_string(TPL)
 
@app.route("/test", methods=["POST"])
def test():
    # Get slider Values
    slider = request.form["slider"]
    print(int(slider))
  
    if (int(slider)>10):
       mymotortest.motor_go(True, "Full" , 600,int(slider)*.0004, False, .05)
       print("Rotating Clockwise")
    
    if (int(slider)<10):
       mymotortest.motor_go(False, "Full" , 600,int(slider)*.001, False, .05)
       print("Rotating Anti-Clockwise")

    
    return render_template_string(TPL)
 
# Run the app on the local development server
if __name__ == "__main__":
    app.run() 

I have pip 20.2.4 installed.
I'm new to coding so any help is welcome!
jm2005
  • 1
  • 1

1 Answers1

0

If you have two versions of Python installed on your system - Python2/Python3, you must use for Python 3.x pip3. When you use just pip command, it will install module for Python2.

Koxo
  • 507
  • 4
  • 10
  • Hey Koxo, first of all thanks for your answer. If I try to install the python libraries mentionend in the tutorial using the `pip3` command I get that error code:" WARNING: You are using pip version 20.2.3; however, version 20.2.4 is available. You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command." However, if I use the suggested command it turns out that I already have pip version 20.2.4 installed on my system. What can I do to solve that error? – jm2005 Nov 02 '20 at 12:55
  • Take a look here https://stackoverflow.com/questions/49489569/python3-trying-to-upgrade-pip3-in-ubuntu-16-04-but-it-doesnt-update/49489881 – Koxo Nov 03 '20 at 08:09