[Python-ideas] Why is there no way to pass PYTHONPATH on the command line?

Paul Moore p.f.moore at gmail.com
Wed Sep 19 20:48:35 CEST 2012


On 19 September 2012 17:36, Gerald Britton <gerald.britton at gmail.com> wrote:
> FYI This works in Windows:
>
> C:\Python26>set PYTHONPATH=c:\temp & python
> Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
> on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import sys
>>>> sys.path
> ['', 'c:\\temp', 'C:\\WINDOWS\\system32\\python26.zip',
> 'C:\\Python26\\DLLs', 'C
> :\\Python26\\lib', 'C:\\Python26\\lib\\plat-win',
> 'C:\\Python26\\lib\\lib-tk', '
> C:\\Python26', 'C:\\Python26\\lib\\site-packages',
> 'C:\\Python26\\lib\\site-pack
> ages\\wx-2.8-msw-unicode']

But it leaves PYTHONPATH set afterwards, and it overwrites any
PYTHONPATH setting you may have had before.


D:\Data>set PY
PYTHONPATH=C:\Temp

D:\Data>(set PYTHONPATH=D:\ & py -3.2)
Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z


D:\Data>set PY
PYTHONPATH=D:\

Paul.



More information about the Python-ideas mailing list