[Tutor] How can I open and use gnome-terminal from a Python script?

Cameron Simpson cs at zip.com.au
Thu Jul 10 00:44:09 CEST 2014


On 09Jul2014 22:16, Walter Prins <wprins at gmail.com> wrote:
>On 9 July 2014 14:43, Jim Byrnes <jf_byrnes at comcast.net> wrote:
>> On 07/09/2014 04:27 AM, Walter Prins wrote:
>>> I forgot to mention I am using Linux (Ubuntu 12.04).
>>
>> I am working my way through a book about breezypythongui which uses Python
>> 3, hence virtualenv.  I found that each time I started to work with it I
>> did the above 3 steps, I was just looking to automatic that repetitive task.
>
>In that case you should put these commands in your .bashrc file so it gets
>set up as your user's default.  (The .bashrc file is somewhat like DOS's
>"autoexec.bat" file, if you're familiar with this, except each user has
>their own .bashrc.)

I am aginst this. It makes _every_ one of your interactive bash instances 
(assuming you're even using bash, though that is probable) use that virtualenv.

>You can also create a shell script that does this for
>you.  (You can install "virtualenv wrapper" which gives you some further
>commands to make working with virtualenvs easier.)

I think this is a better approach.

Even a tiny shell script that sources activate and then execs "$SHELL" (your 
shell, whatever one it is) will ease your pain. Eg:

   #!/bin/sh
   . /path/to/venv/bin/activate
   exec "${SHELL:-/bin/sh}"

Cheers,
Cameron Simpson <cs at zip.com.au>

Many are stubborn in pursuit of the path they have chosen, few in pursuit
of the goal. - Friedrich Nietzsche


More information about the Tutor mailing list