OS: Ubuntu
Device: Jetson Nano developer kit 2GB
I’ve got a python program that I want to launch by double clicking. The reason for this is because I want to control the entire device with just a touchscreen. I’ve written a .sh
file to launch the python program however when I double click it a terminal opens and immediately closes, the same thing happens when I run the .sh
file manually through the terminal.
.sh
file:
#!/usr/bin/env bash
echo "Starting"
sleep 1
cd /home/velotech/workspace
python3 detect.py
The weird thing is that when I run the command python3 detect.py
manually from the terminal the program runs just fine.
Things I’ve tried:
- Made a simple
hello.py
program, this one works both by double clicking the.sh
file and through terminal so I don’t think it has to do with my .sh file
print('Enter your name:')
x = input()
print('Hello, ' + x)
- Added print statements in my python program, I’ve found out that the program stops working after I import two jetson libraries
Jetson.inference
andjetson.utils
.
A snippet of the code fromdetect.py
:
#!/usr/bin/python3
import serial
from gpsZEDF9P.ublox_gps import UbloxGps
import time
import threading as thread
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QMessageBox, QLabel, QVBoxLayout, QHBoxLayout, QFrame, QSizePolicy, QComboBox
from PyQt5 import QtCore
import sys
print("this gets printed")
import jetson.utils
import jetson.inference
print("This does not")
... rest of the code
When I run this from the terminal it works but when I run it through the .sh
file it closes the terminal after the first print statement. So my question is, what could this be?
2
Answers
In case anyone else comes across this, after I updated the libraries Jetson Utils and Jetson Inference it threw a warning saying jetson.utils and jetson.inference were deprecated and to use jetson_utils and jetson_inference instead. After doing so I was able to run the program from a .sh file and by double clicking it
You are running:
Debug by running this instead:
Verify that the identical
$PYTHONPATH
/sys.path
is used in both your terminal and double-click environments.
Take care to
export
a new value for that env varif you notice a mismatch,
or use
conda activate myproject
or the corresponding
venv
command,so the same libraries are available in both environments.