skip to Main Content

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:

  1. 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)
  1. Added print statements in my python program, I’ve found out that the program stops working after I import two jetson libraries Jetson.inference and jetson.utils.
    A snippet of the code from detect.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


  1. Chosen as BEST ANSWER

    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


  2. You are running:

    python3 detect.py
    

    Debug by running this instead:

    python3 -m site
    sleep 30
    

    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 var
    if you notice a mismatch,
    or use conda activate myproject
    or the corresponding venv command,
    so the same libraries are available in both environments.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search