Motors never leave armed stage on python script

I am currently using the Navio2 and a raspberry pi 4b with 4gb of ram. I am using the newest of everything as I just downloaded the stuff today. I am currently working on a basic python script to fly the drone to a target altitude and come down. However, when I run the basic script, the motors just stay in the minimal zone for rotation, no takeoff whatsoever. When I use my RC controller, it works beautifully. What could I be doing wrong in the code below:

####Dependencies###################

from dronekit import connect, VehicleMode, LocationGlobalRelative
import time
import socket
import exceptions
import argparse

###Function definitions for mission####

##Function to connect script to drone
def connectMyCopter():
    parser = argparse.ArgumentParser(description='commands')
    parser.add_argument('--connect')
    args = parser.parse_args()

    connection_string = args.connect

    vehicle = connect(connection_string, wait_ready=True)

    return vehicle

##Function to arm the drone and takeoff into the air##
def arm_and_takeoff(aTargetAltitude):
   # while not vehicle.is_armable:
   #    print("Waiting for vehicle to become armable")
    #    time.sleep(1)

    #Switch vehicle to GUIDED mode and wait for change
    vehicle.mode = VehicleMode("GUIDED")
    while vehicle.mode!="GUIDED":
        print("Waiting for vehicle to enter GUIDED mode")
        time.sleep(1)

    #Arm vehicle once GUIDED mode is confirmed
    vehicle.armed=True
    while vehicle.armed==False:
        print("Waiting for vehicle to become armed.")
        time.sleep(1)

    vehicle.simple_takeoff(aTargetAltitude)

    while True:
        print("Current Altitude: %d"%vehicle.location.global_relative_frame.alt)
        if vehicle.location.global_relative_frame.alt>=aTargetAltitude*.95:
            break
        time.sleep(1)

    print("Target altitude reached")
    return None

#### Mission################################

vehicle=connectMyCopter()
print("About to takeoff..")

vehicle.mode=VehicleMode("GUIDED")
arm_and_takeoff(2) ##Tell drone to fly 2 meters in the sky
vehicle.mode=VehicleMode("LAND") ##Once drone reaches altitude, tell it to land

time.sleep(2)

print("End of function")
print("Arducopter version: %s"%vehicle.version)

while True: 
    time.sleep(2)

vehicle.close()
### End of script

Hi Cole,

Thanks for your patience!

Our python examples may point you in the right direction of the writing. You can also check out the Dronekit package which allows you to fully control your vehicle via scripts.

We don’t have a ready solution for your task so I can hardly be of much help with the exact code lines. However, our users with a similar application may chime in with something useful.