Python error


#1
Starting copter simulator (SITL)

SITL already Downloaded and Extracted.
Ready to boot.
Traceback (most recent call last):
File “/home/dronedojo/courseRoot/dk/dk/LaunchSkyCasterStealth.py”, line 116, in
vehicle = connectMyCopter()
File “/home/dronedojo/courseRoot/dk/dk/LaunchSkyCasterStealth.py”, line 24, in connectMyCopter
sitl = dronekit_sitl.start_default()
File “/home/johnny/.local/lib/python3.9/site-packages/dronekit_sitl/init.py”, line 462, in start_default
sitl.launch(sitl_args, await_ready=True, restart=True)
File “/home/johnny/.local/lib/python3.9/site-packages/dronekit_sitl/init.py”, line 251, in launch
caps = ArdupilotCapabilities(self.path)
File “/home/johnny/.local/lib/python3.9/site-packages/dronekit_sitl/init.py”, line 160, in init
process = subprocess.Popen([path, ‘–help’], stdout=subprocess.PIPE)
File “/usr/lib/python3.9/subprocess.py”, line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “/usr/lib/python3.9/subprocess.py”, line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: ‘/home/johnny/.dronekit/sitl/copter-3.3/apm’
johnny@johnny-desktop:/home/dronedojo/courseRoot/dk/dk$ python3 LaunchSkyCasterStealth.py
Starting copter simulator (SITL)
SITL already Downloaded and Extracted.
Ready to boot.
Traceback (most recent call last):
File “/home/dronedojo/courseRoot/dk/dk/LaunchSkyCasterStealth.py”, line 116, in
vehicle = connectMyCopter()
File “/home/dronedojo/courseRoot/dk/dk/LaunchSkyCasterStealth.py”, line 24, in connectMyCopter
sitl = dronekit_sitl.start_default()
File “/home/johnny/.local/lib/python3.9/site-packages/dronekit_sitl/init.py”, line 462, in start_default
sitl.launch(sitl_args, await_ready=True, restart=True)
File “/home/johnny/.local/lib/python3.9/site-packages/dronekit_sitl/init.py”, line 251, in launch
caps = ArdupilotCapabilities(self.path)
File “/home/johnny/.local/lib/python3.9/site-packages/dronekit_sitl/init.py”, line 160, in init
process = subprocess.Popen([path, ‘–help’], stdout=subprocess.PIPE)
File “/usr/lib/python3.9/subprocess.py”, line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “/usr/lib/python3.9/subprocess.py”, line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: ‘/home/johnny/.dronekit/sitl/copter-3.3/apm’

Any idea of how to resolve this? I am trying to migrate all the files from the VirtualBox onto a physical Ubuntu RaspberryPi & am close to having it working…Minus this last error message… Any ideas?


#2

Hi there @northdacoder!

Sorry for the delay.

You may run into problems because the VM (in the course) uses python2 and it looks like you’re trying to port to python3. There is a good guide on how you can get the course material up and running with python3 and ubuntu 20.04 by @dash, though I have not done this yet.

May I ask why you’re wanting to run SITL from the PI as opposed to on a desktop/laptop?


#3

Hello there,

@northdacoder did get this issue fixed?. I have the same problem, I’m using my raspberry pi to run the scripts, and anyone I pick from the Dronekit examples folder gives me the same error. Please let me know if you get a solution for this problem.

Regards,


#4

If @northdacoder doesn’t respond, list out your build steps and I will try to help.


#5

Hello @jax200,

Thanks for reaching out. I not doing nothing out of the normal, I have a raspberry pi 4 that I’m planning to use as the companion computer, I just follow the step describes by this youtube video: https://www.youtube.com/watch?v=kB9YyG2V-nA&t=1428s which I belive it’s was made from the team that runs this forum, Oh BTW it a very good video. I copy that same script that has been build on the video and it’s work fine for me but, any script I try to run from the dronekit example folder I’m getting this error:

Start simulator (SITL)
Starting copter simulator (SITL)
SITL already Downloaded and Extracted.
Ready to boot.
Traceback (most recent call last):
File “hello.py”, line 5, in
sitl = dronekit_sitl.start_default()
File “/home/pi/.local/lib/python2.7/site-packages/dronekit_sitl/init.py”, line 462, in start_default
sitl.launch(sitl_args, await_ready=True, restart=True)
File “/home/pi/.local/lib/python2.7/site-packages/dronekit_sitl/init.py”, line 251, in launch
caps = ArdupilotCapabilities(self.path)
File “/home/pi/.local/lib/python2.7/site-packages/dronekit_sitl/init.py”, line 160, in init
process = subprocess.Popen([path, ‘–help’], stdout=subprocess.PIPE)
File “/usr/lib/python2.7/subprocess.py”, line 394, in init
errread, errwrite)
File “/usr/lib/python2.7/subprocess.py”, line 1047, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error

I try adding this lines #!/usr/bin/env python; # -- coding: utf-8 -- at the top of the script but I’m getting the same result. I really don’t know what I’m missing or what I need to add in order to have those examples scripts running.

I really appreciate all your help, if it’s there anything else you need please let me know I’ll be more than happy sharing it with you.

Regards,


#6

Why do you want to run the SITL on a Raspberry Pi? You should do this on a PC or laptop. Run the dronekit code on the RPi for real drone flights. Let me know your thoughts.


#7

Hello jax200

I found out I was running the wrong script. I’m just needed to run a simple test communication between the Pixhwak and the raspberry and I believe that the script you provided on the video gives me what I need. from now on I’ll continue dining some flight tests. Thanks for all your support.


#8

Hi there, I fixed it.

I got the same error and figured that it was because I was running an ARM version of Ubuntu 20.04 on parallels on my M1 mac.

You have to build the binaries for the ARM version, and it’s a simple process.

Run the following code in your terminal:

cd ~/courseRoot/apm2/ardupilot/
make -j4 sitl

After running the above, the build process should finish and the build directory should be listed. Mine was at:

/home/parallels/courseRoot/apm2/ardupilot/build/sitl/bin/

cd into the directory and copy the new build (named arducopter) to replace the old build which is in @northdacoder case (the apm file), located at,

/home/johnny/.dronekit/sitl/copter-3.3/apm

Don’t forget to rename your new build to ‘apm’.

Now execute and watch your sitl come up via dronekit.