Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Launch Options
#1
I'm not sure if this is more a Python question or a Linux question, but here goes: I have a script file tied to the key combo Ctrl+Alt+P to navigate to my script folder and run Python. That part works.
#!/bin/bash
mate-terminal --working-directory="/home/flexico/Documents/Python_Scripts" --title="Python" --command python
However, I also want it to run a few lines of Python script, like import some standard libraries so I don't have to re-type them in every time. How do I do that? I tried adjusting the program like so:
#!/bin/bash
mate-terminal --working-directory="/home/flexico/Documents/Python_Scripts" --title="Python" --command "python /home/flexico/python_start.py"
But it just opens a blank Terminal window with a flashing cursor, which disappears when I click on it.
Reply
#2
(Dec-06-2016, 02:28 AM)Flexico Wrote: I have a script file tied to the key combo Ctrl+Alt+P to navigate to my script folder and run Python.
What are you trying to do? Just run the script "python_start.py"? In linux all you need to do is
$ cd
$ python python_start.py
Quote:But it just opens a blank Terminal window with a flashing cursor, which disappears when I click on it.
youd have to show us what the script contains.
Recommended Tutorials:
Reply
#3
What I want is for the Python window to stay open so I can input further commands. All the script does is import a few modules.
Reply
#4
(Dec-06-2016, 02:46 AM)Flexico Wrote: What I want is for the Python window to stay open so I can input further commands.
Then just do the Windows trick of add input at the end of the script to keep it open.
Recommended Tutorials:
Reply
#5
Got answered here: http://www.linuxquestions.org/questions/...ost5638499
Reply
#6
(Dec-06-2016, 11:18 AM)Flexico Wrote: Got answered here: http://www.linuxquestions.org/questions/...ost5638499

Your final solution in the link does not actually correspond to the question you asked here, but if your happy, we're happy.  btw, there is no "double click" to run a script in linux, that's Windows. If you have the proper "shebang" line at the beginning of you script, for example:

#!/usr/bin/env python
Note in the above example, this will invoke the default Python interpreter (in linux, usually python 2)
you simply type "./your_script.py

As metulburr pointed out, unless you add something to keep the terminal open, python will run the script and the close the terminal (unless of course, your running the script from within an existing terminal.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#7
Ok, you guys here completely misunderstood what I was asking.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Launch Python IDLE Shell from terminal Pavel_47 5 1,143 Feb-17-2023, 02:53 PM
Last Post: Pavel_47
  Performance options for sys.stdout.writelines dgrunwal 11 2,996 Aug-23-2022, 10:32 PM
Last Post: Pedroski55
  Launch Windows Application OEMS1 0 2,096 Mar-26-2021, 07:42 PM
Last Post: OEMS1
Photo Python won`t launch error newbieee 0 1,734 Feb-02-2021, 11:51 PM
Last Post: newbieee
  Can argparse support undocumented options? pjfarley3 3 2,121 Aug-14-2020, 06:13 AM
Last Post: pjfarley3
  Launch another python command without waiting for a return. SpongeB0B 13 10,690 Jun-18-2020, 10:45 AM
Last Post: Yoriz
  win32 API: Launch Application to RDP session from background process python script rangeshgupta 0 2,091 May-28-2020, 09:41 PM
Last Post: rangeshgupta
  Help with options raiden 1 1,883 Aug-30-2019, 12:57 AM
Last Post: scidam
  how to specify options or tickle python to output points swept by the optimization? bsmile 3 2,610 Aug-02-2019, 10:31 PM
Last Post: scidam
  error message on program launch DJPY1175 0 1,722 Jun-10-2019, 08:40 AM
Last Post: DJPY1175

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020