Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #11846

Re: Execute script from ipython

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'bash': 0.09; 'filename': 0.09; 'am,': 0.12; '$path': 0.16; '6:00': 0.16; 'patching': 0.16; 'performed.': 0.16; 'received:209.85.213.174': 0.16; 'received :mail-yx0-f174.google.com': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'linux': 0.17; 'cheers,': 0.18; 'cc:no real name:2**0': 0.20; 'this?': 0.21; 'cc:2**0': 0.22; 'header:In- Reply-To:1': 0.22; 'aug': 0.24; 'tried': 0.26; 'function': 0.27; 'all,': 0.28; 'correct': 0.28; 'pass': 0.29; 'message- id:@mail.gmail.com': 0.29; 'script': 0.29; 'cc:addr:python.org': 0.30; 'module': 0.30; 'seem': 0.31; 'changing': 0.31; 'chris': 0.32; 'instead': 0.33; 'fri,': 0.36; 'skip:" 10': 0.36; 'run': 0.37; 'but': 0.37; 'could': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'either': 0.39; 'absolute': 0.39; "i'd": 0.40; 'subject:from': 0.40; 'might': 0.40; 'your': 0.61; 'kind': 0.61; 'desire.': 0.84; 'sender:addr:chris': 0.84; 'url:rebertia': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=qlJOVUJXsJOThQ8GxHTw4XOAARYIDU/mN+3vRA0VVBA=; b=Ar/6zyRYjfOGWR/GBFAdWZD5WgX/PAdmDS6BWNP0oZ2N/qJgjX9JcdgsMDd1UX7Yi4 df2NYsD0nA2RIKK3fSVSZNu3aWOMSYa84lpQJLKqY3OfmsFEcDnCNiVNDIE+KCnqFYcl 3WSYGZcySOWFXlH6g02+QlUc1lAUWuuQ/PzQc=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <CAH13Zgg1v=AWs+Ri1zD=QQozbsaHVDoOcVsgC8+7n1Kxb6TQ6A@mail.gmail.com>
References <CAH13Zgg1v=AWs+Ri1zD=QQozbsaHVDoOcVsgC8+7n1Kxb6TQ6A@mail.gmail.com>
Date Fri, 19 Aug 2011 08:11:38 -0700
X-Google-Sender-Auth wI0QcwY-xW-Y7cRRpRie5OBpLu0
Subject Re: Execute script from ipython
From Chris Rebert <clp2@rebertia.com>
To Johan Ekh <ekh.johan@gmail.com>
Content-Type text/plain; charset=UTF-8
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.221.1313766701.27778.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1313766701 news.xs4all.nl 23941 [2001:888:2000:d::a6]:50199
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:11846

Show key headers only | View raw


On Fri, Aug 19, 2011 at 6:00 AM, Johan Ekh <ekh.johan@gmail.com> wrote:
> Hi all,
> I have a script "myscript.py" located in "/usr/local/bin" on my linux box.
> I can execute it in ipython with
>
> run /usr/local/bin/myscript.py
>
> but not with
>
> run myscript.py
>
> even though /usr/local/bin is in my $PATH and in my $PYTHONPATH.
>
> What should I do to correct this?

Given that %run takes a filename and not a module name, I doubt
PYTHONPATH matters. ipython's docs for %run don't seem to indicate
that a search of any kind is performed. So, I'd say you have to either
pass a valid absolute or relative path to myscript.py, or run
myscript.py from bash instead of ipython.

Changing your script's shebang line to ipython might also work
(haven't tried it myself). Or you could try patching ipython's run()
function to add this search feature you desire.

Cheers,
Chris
--
http://rebertia.com

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Execute script from ipython Chris Rebert <clp2@rebertia.com> - 2011-08-19 08:11 -0700

csiph-web