Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:\\ 30': 0.09; 'python': 0.11; 'interpreter': 0.15; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:when': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'windows': 0.20; "skip:' 40": 0.22; 'bit': 0.23; '2015': 0.23; 'module': 0.23; 'import': 0.24; 'header :User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'found.': 0.27; 'command': 0.28; 'cest': 0.29; 'work.': 0.30; 'this?': 0.34; 'could': 0.35; 'to:addr:python-list': 0.35; 'set.': 0.35; 'something': 0.35; 'skip:o 20': 0.35; 'but': 0.36; 'there': 0.36; 'modules': 0.36; 'subject:: ': 0.37; 'instead': 0.38; 'received:org': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'mark': 0.40; 'received:de': 0.40; '>>>>>': 0.66; 'saturday': 0.66; 'cecil': 0.84; 'schreef': 0.84; 'westerhof': 0.84; '\xe2\x80\xa6': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: PYTHONPATH when calling from ipython Date: Sat, 23 May 2015 15:25:04 +0200 Organization: None References: <874mn5qjc8.fsf@Equus.decebal.nl> <87iobjpnt4.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Gmane-NNTP-Posting-Host: p57bd8bd4.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432387517 news.xs4all.nl 2900 [2001:888:2000:d::a6]:41831 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3816 X-Received-Body-CRC: 1000326507 Xref: csiph.com comp.lang.python:91126 Cecil Westerhof wrote: > Op Saturday 23 May 2015 11:12 CEST schreef Mark Lawrence: > >> On 22/05/2015 06:20, Cecil Westerhof wrote: >>> I am looking into using ipython instead of bash. But when I call a >>> python program from ipython PYTHONPATH is not set. So pythonscripts >>> that need a module through PYTHONPATH will not work. >>> >>> I could do something like: >>> !PYTHONPATH=~/Python/PythonLibrary python2 … >>> >>> But I find that a little bit cumbersome. Is there a better way to >>> do it? >>> >> >> What makes you think this? Have you tried:- >> >>>>> import os >>>>> os.environ['PYTHONPATH'] >> 'C:\\Users\\Mark\\Documents\\Cash\\Python;C: \\Users\\Mark\\Documents\\MyPython' >> >> That might be from the command line interpreter but it also works >> the same from iPython for me on Windows 8.1. > > That does not change anything. The modules are not found. Also not > when using %run. That may be because ~ is not expanded. Try os.environ["PYTHONPATH"] = os.path.expanduser("~/Python/PythonLibary")