Executing a python program in a raspberry pi

조회 수: 18 (최근 30일)
James Carter
James Carter 2020년 11월 15일
댓글: James Carter 2020년 11월 27일
I am trying to execute a python progam that is located in a folder on a raspberry pi using a Matlab script. You execute this file in the pi using the command "sudo ./". I have attempted to do this using the following command: system(mypi,"/home/pi/Downloads/LeptonModulemaster/software/Raspberrypi_capture/Raspberrypi_capture","sudo").
Please advise.
Thanks

답변 (1개)

Nagasai Bharat
Nagasai Bharat 2020년 11월 24일
Hi,
According to my understanding you want to run a python file in the raspberry pi to be executed from MATLAB. After the support package is installed and a connection has been creating between raspberry pi and MATLAB.
After creating a connection you can use system function as instructed in documentation.
To execute a python program you use "python filename.py" or "python3 filename.py". Try the following line of code
system(mypi,'python /home/pi/Downloads/LeptonModulemaster/software/Raspberrypi_capture/Raspberrypi_capture.py','sudo');
For more information have a look at this link.
  댓글 수: 1
James Carter
James Carter 2020년 11월 27일
Thanks for the quick response.
I made the appropriate change, but, got the following:
>> system(mypi,'python /home/pi/Downloads/LeptonModule-master/software/raspberrypi_capture/raspberrypi_capture','sudo')
Error executing command "sudo python
/home/pi/Downloads/LeptonModule-master/software/raspberrypi_capture/raspberrypi_capture". Details:
STDERR: File
"/home/pi/Downloads/LeptonModule-master/software/raspberrypi_capture/raspberrypi_capture", line 1
SyntaxError: Non-ASCII character '\x8b' in file
/home/pi/Downloads/LeptonModule-master/software/raspberrypi_capture/raspberrypi_capture on line 2, but
no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
STDOUT:
So, I added to following to the Make file (to deal with the encoding issue), but got the same error
#!/usr/bin/env python
# -*- coding: utf-8 -*-
How should I handle this?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Raspberry Pi Hardware에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by