Danilk
Posts: 108
Joined: Wed Feb 01, 2017 7:47 pm
Location: Russia, St-Peterburg

run script in terminal problem

Tue Apr 25, 2017 10:06 am

Code: Select all

python /home/pi/Documents/Monkey\ Studio/Projects/metro_uic.py
Traceback (most recent call last):
  File "/home/pi/Documents/Monkey Studio/Projects/metro_uic.py", line 10, in <module>
    from mainwindow import MainWindow
  File "/home/pi/Documents/Monkey Studio/Projects/mainwindow.py", line 12, in <module>
    from UserData import UserData
  File "/home/pi/Documents/Monkey Studio/Projects/UserData.py", line 10, in <module>
    Ui_InputWindow, QtBaseClass = uic.loadUiType(InputWindow)
  File "/usr/lib/python2.7/dist-packages/PyQt4/uic/__init__.py", line 210, in loadUiType
    winfo = compiler.UICompiler().compileUi(uifile, code_string, from_imports, resource_suffix)
  File "/usr/lib/python2.7/dist-packages/PyQt4/uic/Compiler/compiler.py", line 139, in compileUi
    w = self.parse(input_stream, resource_suffix)
  File "/usr/lib/python2.7/dist-packages/PyQt4/uic/uiparser.py", line 984, in parse
    document = parse(filename)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1182, in parse
    tree.parse(source, parser)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 647, in parse
    source = open(source, "rb")
IOError: [Errno 2] No such file or directory: 'datainput.ui'
but with idle2,3 everything starts properly

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: run script in terminal problem

Tue Apr 25, 2017 10:10 am

One thing to try. Rather than just specifying the file name "datainput.ui" specify the full absolute path.
For example "/home/pi/projects/datainput.ui"
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Danilk
Posts: 108
Joined: Wed Feb 01, 2017 7:47 pm
Location: Russia, St-Peterburg

Re: run script in terminal problem

Tue Apr 25, 2017 10:16 am

should i set PATH for my app?
echo $PATH

Code: Select all

/home/pi/Documents/Monkey Studio/Projects/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
no result

Danilk
Posts: 108
Joined: Wed Feb 01, 2017 7:47 pm
Location: Russia, St-Peterburg

Re: run script in terminal problem

Tue Apr 25, 2017 11:16 am

inside script dir everything is ok

Code: Select all

pi@raspberrypi:~/Documents/Monkey Studio/Projects $ python "/home/pi/Documents/Monkey Studio/Projects/metro_uic.py""/home/pi/Documents/Monkey Studio/Projects/metro_uic.py"
but outside command is not working properly

how to autoboot my script?

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: run script in terminal problem

Tue Apr 25, 2017 11:19 am

Did you try what i suggested?
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Danilk
Posts: 108
Joined: Wed Feb 01, 2017 7:47 pm
Location: Russia, St-Peterburg

Re: run script in terminal problem

Tue Apr 25, 2017 11:31 am

i did
script runs but no icons,images…

dos style helped
created bash script

Code: Select all

#!/bin/bash
cd /
cd /home/pi/Documents/Monkey\ Studio/Projects
python metro_uic.py
this script inside .desktop file boots!

Code: Select all

[Desktop Entry]
Type=Application
Name=owen
Comment=owen
Exec=bash /home/pi/Documents/Monkey\ Studio/Projects/run

ghostinthepi
Posts: 9
Joined: Fri Feb 24, 2017 6:25 am

Re: run script in terminal problem

Thu Apr 27, 2017 6:33 am

Idle will boot files because when you load the .py file to the idle terminal, it understands the path.

However with the command line in the raspberry pi you need to define the path or have the working directory be where the file is located. You are getting an IO error because you cannot locate the file.

So navigate to the directory of the file location and then run:

Code: Select all

python metrouic.py
Please let me know if this works for you, Danlik.
:mrgreen:

Danilk
Posts: 108
Joined: Wed Feb 01, 2017 7:47 pm
Location: Russia, St-Peterburg

Re: run script in terminal problem

Thu Apr 27, 2017 6:50 am

ghostinthepi wrote: Please let me know if this works for you, Danlik.
:mrgreen:
i wrote above that from the script dir everything is ok
so run script goes to my dir and starts python metro_uic.py like .bat windows file)))

Return to “Python”