Why is there no way to pass PYTHONPATH on the command line?
![](https://secure.gravatar.com/avatar/d7ff36e4d7c8060fadaa7c20f4a5649e.jpg?s=120&d=mm&r=g)
Why is there no way to pass PYTHONPATH on the command line? Oversight or intentional? Given path_item/something.py python -p path_item -c "import something; something.foo()" I am aware that the __main__.py behavior lessens the need for this significantly.
![](https://secure.gravatar.com/avatar/3ab03c2cab54cc59d04b4b1cba58ab57.jpg?s=120&d=mm&r=g)
On Fri, Sep 14, 2012 at 5:24 PM, Daniel Holth <dholth@gmail.com> wrote:
Why is there no way to pass PYTHONPATH on the command line? Oversight or intentional?
Given path_item/something.py
python -p path_item -c "import something; something.foo()"
I am aware that the __main__.py behavior lessens the need for this significantly.
PYTHONPATH=whatever python -c "import something; something.foo()" Mike
![](https://secure.gravatar.com/avatar/d7ff36e4d7c8060fadaa7c20f4a5649e.jpg?s=120&d=mm&r=g)
On Fri, Sep 14, 2012 at 6:10 PM, Mike Graham <mikegraham@gmail.com> wrote:
On Fri, Sep 14, 2012 at 5:24 PM, Daniel Holth <dholth@gmail.com> wrote:
Why is there no way to pass PYTHONPATH on the command line? Oversight or intentional?
Given path_item/something.py
python -p path_item -c "import something; something.foo()"
I am aware that the __main__.py behavior lessens the need for this significantly.
PYTHONPATH=whatever python -c "import something; something.foo()"
Mike
Yes, I've heard of that one. Does it work on Windows too?
![](https://secure.gravatar.com/avatar/d995b462a98fea412efa79d17ba3787a.jpg?s=120&d=mm&r=g)
On 14 September 2012 23:11, Daniel Holth <dholth@gmail.com> wrote:
On Fri, Sep 14, 2012 at 6:10 PM, Mike Graham <mikegraham@gmail.com> wrote:
On Fri, Sep 14, 2012 at 5:24 PM, Daniel Holth <dholth@gmail.com> wrote:
Why is there no way to pass PYTHONPATH on the command line? Oversight or intentional?
Given path_item/something.py
python -p path_item -c "import something; something.foo()"
I am aware that the __main__.py behavior lessens the need for this significantly.
PYTHONPATH=whatever python -c "import something; something.foo()"
Mike
Yes, I've heard of that one. Does it work on Windows too?
No. Sadly. Paul.
![](https://secure.gravatar.com/avatar/3a5cfb2cee5b7abb9ab4c805e36f2d19.jpg?s=120&d=mm&r=g)
On 15 September 2012 08:40, Paul Moore <p.f.moore@gmail.com> wrote:
On 14 September 2012 23:11, Daniel Holth <dholth@gmail.com> wrote:
On Fri, Sep 14, 2012 at 6:10 PM, Mike Graham <mikegraham@gmail.com> wrote:
PYTHONPATH=whatever python -c "import something; something.foo()"
Mike
Yes, I've heard of that one. Does it work on Windows too?
No. Sadly.
Unless you're using either cygwin or (my preference) msys < http://www.mingw.org/wiki/MSYS>. Tim Delaney
![](https://secure.gravatar.com/avatar/dd4761743695d5efd3692f2a3b35d37d.jpg?s=120&d=mm&r=g)
On Fri, Sep 14, 2012 at 3:24 PM, Daniel Holth <dholth@gmail.com> wrote:
Why is there no way to pass PYTHONPATH on the command line? Oversight or intentional?
Given path_item/something.py
python -p path_item -c "import something; something.foo()"
Do you mean something along the lines of http://bugs.python.org/issue13475? This would add --path0 and --nopath0 as commandline options. Of course, this would only be in Python 3.4 (if it makes it in at all). -eric
![](https://secure.gravatar.com/avatar/047f2332cde3730f1ed661eebb0c5686.jpg?s=120&d=mm&r=g)
On Fri, Sep 14, 2012 at 3:48 PM, Eric Snow <ericsnowcurrently@gmail.com> wrote:
On Fri, Sep 14, 2012 at 3:24 PM, Daniel Holth <dholth@gmail.com> wrote:
Why is there no way to pass PYTHONPATH on the command line? Oversight or intentional?
Given path_item/something.py
python -p path_item -c "import something; something.foo()"
Do you mean something along the lines of http://bugs.python.org/issue13475? This would add --path0 and --nopath0 as commandline options. Of course, this would only be in Python 3.4 (if it makes it in at all).
Why is the proposal --path0 and not --path? (The only utility I know with a command line option spelled as "foo0" is find, where -print0 means "like -print, but append \0 instead of \n".) -- --Guido van Rossum (python.org/~guido)
![](https://secure.gravatar.com/avatar/dd4761743695d5efd3692f2a3b35d37d.jpg?s=120&d=mm&r=g)
On Fri, Sep 14, 2012 at 5:03 PM, Guido van Rossum <guido@python.org> wrote:
On Fri, Sep 14, 2012 at 3:48 PM, Eric Snow <ericsnowcurrently@gmail.com> wrote:
... issue13475 ... Why is the proposal --path0 and not --path? (The only utility I know with a command line option spelled as "foo0" is find, where -print0 means "like -print, but append \0 instead of \n".)
It's meant to allow you to explicitly manage the sys.path[0] value that gets set implicitly. That it fits Daniel's use case (as I understand it) is not coincidental, but it's not meant as a wholesale substitute for PYTHONPATH. That would be a separate proposal (which I believe exists in the tracker already). -eric
![](https://secure.gravatar.com/avatar/d7ff36e4d7c8060fadaa7c20f4a5649e.jpg?s=120&d=mm&r=g)
Surely it should be the same as python path, at the front, and use - E to ignore the environment On Sep 14, 2012 7:17 PM, "Eric Snow" <ericsnowcurrently@gmail.com> wrote:
On Fri, Sep 14, 2012 at 5:03 PM, Guido van Rossum <guido@python.org> wrote:
On Fri, Sep 14, 2012 at 3:48 PM, Eric Snow <ericsnowcurrently@gmail.com> wrote:
... issue13475 ... Why is the proposal --path0 and not --path? (The only utility I know with a command line option spelled as "foo0" is find, where -print0 means "like -print, but append \0 instead of \n".)
It's meant to allow you to explicitly manage the sys.path[0] value that gets set implicitly. That it fits Daniel's use case (as I understand it) is not coincidental, but it's not meant as a wholesale substitute for PYTHONPATH. That would be a separate proposal (which I believe exists in the tracker already).
-eric
participants (6)
-
Daniel Holth
-
Eric Snow
-
Guido van Rossum
-
Mike Graham
-
Paul Moore
-
Tim Delaney