Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Python search path (on Windows)

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


wb at noname

Oct 22, 2008, 2:03 AM

Post #1 of 4 (131 views)
Permalink
Python search path (on Windows)

I would like to execute a Python script from Windows command line:

Python myscript.py

This works if myscript.py resides in the current folder. My question is:
Is it possible to execute the command above from another folder?

I put the script's folder in the PYTHONPATH environment variable but this
didn't help.

Thanks for your help!


--
http://mail.python.org/mailman/listinfo/python-list


gagsl-py2 at yahoo

Oct 22, 2008, 2:32 AM

Post #2 of 4 (106 views)
Permalink
Re: Python search path (on Windows) [In reply to]

En Wed, 22 Oct 2008 07:03:48 -0200, wooly booly <wb[at]noname.com> escribió:

> I would like to execute a Python script from Windows command line:
>
> Python myscript.py
>
> This works if myscript.py resides in the current folder. My question is:
> Is it possible to execute the command above from another folder?

Yes, use:
python path\to\the\actual\location\of\myscript.py

> I put the script's folder in the PYTHONPATH environment variable but this
> didn't help.

No, PYTHONPATH contains the directories searched when trying to import a
module -- it's not used to locate the main script.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


deets at nospam

Oct 22, 2008, 3:10 AM

Post #3 of 4 (112 views)
Permalink
Re: Python search path (on Windows) [In reply to]

wooly booly wrote:

> I would like to execute a Python script from Windows command line:
>
> Python myscript.py
>
> This works if myscript.py resides in the current folder. My question is:
> Is it possible to execute the command above from another folder?
>
> I put the script's folder in the PYTHONPATH environment variable but this
> didn't help.

Then you could try

Python -m myscript

Diez


--
http://mail.python.org/mailman/listinfo/python-list


antroy at gmail

Oct 22, 2008, 5:07 AM

Post #4 of 4 (102 views)
Permalink
Re: Python search path (on Windows) [In reply to]

On Oct 22, 10:03 am, "wooly booly" <w...@noname.com> wrote:
> I would like to execute a Python script from Windows command line:
>
> Python myscript.py
>
> This works if myscript.py resides in the current folder. My question is:
> Is it possible to execute the command above from another folder?
>
> I put the script's folder in the PYTHONPATH environment variable but this
> didn't help.
>
> Thanks for your help!

You can put the script directory in the PATH environment variable, and
call it with just:

myscript.py
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.