简体   繁体   English

如何在 Raspbian 上的 python 中运行可执行文件?

[英]How to run an executable file in python on Raspbian?

Hello i'm been having some trouble with run a exe file on python.您好,我在 python 上运行 exe 文件时遇到了一些问题。 I'm using a Raspberry Pi and have not been able to find an answer that works.我正在使用 Raspberry Pi,但无法找到有效的答案。 I've tried to use subprocess我试过使用子流程

import subprocess
subprocess.Popen("/home/pi/Desktop/file.exe")

only to get [Errno 8] Exec format error.只是为了得到 [Errno 8] Exec 格式错误。 I get the same thing with subprocess.call.我用 subprocess.call 得到同样的结果。

I tried to use os我尝试使用 os

import os
os.system("/home/pi/Desktop/file.exe")

I get no errors there but nothing happens.我在那里没有错误,但没有任何反应。

I know the exe file works when I click on it, I know that the file path is correct.当我点击它时,我知道 exe 文件有效,我知道文件路径是正确的。 Is there anyway I could run this exe with my python program.无论如何我可以用我的python程序运行这个exe文件。

Okay, .exe files are windows executables.好的, .exe文件是 Windows 可执行文件。 They are not compiled for Linux (Raspian) at all.它们根本不是为 Linux (Raspian) 编译的。 however you can find the extension of your file by opening a terminal window, navigate to the desktop with cd ~/Desktop/ Then run ls -la to list the folder contents.但是,您可以通过打开终端窗口找到文件的扩展名,使用cd ~/Desktop/导航到桌面,然后运行ls -la以列出文件夹内容。

On the other hand, if you are meaning a Python file to run then it will have the extension .py .另一方面,如果您的意思是要运行 Python 文件,那么它将具有扩展名.py To run these open up your terminal and navigate to your Desktop again using cd ~/Desktop/ and run it with python file.py要运行这些,请打开您的终端并使用cd ~/Desktop/再次导航到您的桌面并使用python file.py运行它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM