简体   繁体   中英

Raspberry pi RPi.GPIO module for executable files

I want to run a simple python program to glow LED. I want to run as executable file on my raspberry pi. my simple test.py code is

print"Welcome to LED program"
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(25,GPIO.OUTPUT)
GPIO.OUTPUT(25,True)

this program runs fine if i use

sudo python test.py

now i convert it into executable file

sudo pyinstaller test.py

and execute it by

sudo ./test

output gives welcome to LED program. Import error: No module name RPi.GPIO.

I used the 1st print command to ensure that executable file conversion is correct and the program is executing correctly.

Now what happened to RPi.GPIO? why the module is not found in case of a executable file??

Some Python scripts import modules in ways that PyInstaller cannot detect.

You can solve this with similar way to this:

sudo pyinstaller --onefile --paths=\your-path\Lib\site-packages  .\test.py

For more detail

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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