How to run Python file?

Discussion in 'Python' started by mistral, Sep 2, 2006.

  1. mistral

    mistral Guest

    mistral, Sep 2, 2006
    #1
    1. Advertising

  2. Pontus Ekberg, Sep 2, 2006
    #2
    1. Advertising

  3. mistral

    zefciu Guest

    Pontus Ekberg wrote:
    > mistral wrote:
    >
    >> I have installed ActivePython
    >> http://www.activestate.com/Products/ActivePython/
    >> How I can run Python file, test.py?

    >
    > $ python test.py
    >
    > or
    >
    > $ ./test.py (if test.py is executable)
    >
    >

    Thats if you use un*x. If you word under windows, the first would work,
    but rather use some IDE like IDLE or SPE than mess with the windows
    command line. Then you just load the file and run it from the menu.

    zefciu
     
    zefciu, Sep 2, 2006
    #3
  4. mistral

    Ant Guest

    zefciu wrote:
    > Pontus Ekberg wrote:

    ....
    > > $ python test.py
    > >
    > > or
    > >
    > > $ ./test.py (if test.py is executable)
    > >
    > >

    > Thats if you use un*x. If you word under windows, the first would work,


    As would:

    > test.py


    Assuming python grabbed the .py extensions correctly (which it shouold
    have done with any recent version).
     
    Ant, Sep 2, 2006
    #4
  5. mistral

    Rick Zantow Guest

    "Ant" <> wrote in news:1157218244.750434.36220
    @h48g2000cwc.googlegroups.com:

    >
    > zefciu wrote:
    >> Pontus Ekberg wrote:

    > ...
    >> > $ python test.py
    >> >
    >> > or
    >> >
    >> > $ ./test.py (if test.py is executable)
    >> >
    >> >

    >> Thats if you use un*x. If you word under windows, the first would

    work,
    >
    > As would:
    >
    >> test.py

    >
    > Assuming python grabbed the .py extensions correctly (which it shouold
    > have done with any recent version).
    >
    >


    As would:

    > test


    .... assuming you're on windows (Win2K or WinXP at least) and you've
    added ".py" to your PATHEXT environment variable.

    --
    rzed
     
    Rick Zantow, Sep 2, 2006
    #5
  6. mistral

    mistral Guest

    Rick Zantow пиÑал(а):

    > "Ant" <> wrote in news:1157218244.750434.36220
    > @h48g2000cwc.googlegroups.com:



    > zefciu wrote:
    > Pontus Ekberg wrote:
    > ...
    > $ python test.py
    >
    > or
    >
    > $ ./test.py (if test.py is executable)
    >
    >
    > Thats if you use un*x. If you word under windows, the first would

    work,
    >
    > As would:
    >
    >> test.py

    >
    > Assuming python grabbed the .py extensions correctly (which it

    shouold
    > have done with any recent version).
    >
    >


    > As would:


    > test


    ... assuming you're on windows (Win2K or WinXP at least) and you've
    added ".py" to your PATHEXT environment variable.

    > --
    > rzed


    -------------

    Assuming I have Windows XP, and I installed ActiveState Python. No any
    other additional manipulations were done, no any PATHEXTes environment
    variables, etc, etc, nothing. How many preparatory work required to run
    one small python file?
     
    mistral, Sep 3, 2006
    #6
  7. mistral

    Rick Zantow Guest

    "mistral" <> wrote in news:1157239512.139823.15650
    @74g2000cwt.googlegroups.com:

    [...]
    > Assuming I have Windows XP, and I installed ActiveState Python. No any
    > other additional manipulations were done, no any PATHEXTes environment
    > variables, etc, etc, nothing. How many preparatory work required to

    run
    > one small python file?
    >


    I hope I'm understanding your question correctly.

    I can't really answer with regard to ActiveState's version. I've only
    used the Python.org binary installation for a long time, and it does set
    up the path on installation. I don't think it adds the PATHEXT, but I
    really don't remember; I've had some version on my computer since Python
    1.5.2. Without that, though, all you'd need would be to type
    > python test.py

    .... given the other assumptions you've indicated. Oh, if you are running
    the python program (located in a directory not in your path) from some
    other directory, you'd need to specify the full pathname, I suppose,
    like
    > python c:\dir\test.py


    I'd assume that ActiveState also sets the path up, but again, I can't
    say for sure that it does. If it doesn't, then you'd add the Python root
    directory to your path or else you'd have to specify *that* each time as
    well.

    --
    rzed
     
    Rick Zantow, Sep 3, 2006
    #7
  8. On 2 Sep 2006 16:25:12 -0700, "mistral" <>
    declaimed the following in comp.lang.python:


    >
    > Assuming I have Windows XP, and I installed ActiveState Python. No any
    > other additional manipulations were done, no any PATHEXTes environment
    > variables, etc, etc, nothing. How many preparatory work required to run
    > one small python file?


    How small a file?

    (watch out for line wraps)

    C:\Documents and Settings\Dennis Lee Bieber>echo print "hello world"
    >test.py


    C:\Documents and Settings\Dennis Lee Bieber>test
    hello world

    C:\Documents and Settings\Dennis Lee Bieber>

    C:\Documents and Settings\Dennis Lee Bieber>python -V
    Python 2.4.3

    C:\Documents and Settings\Dennis Lee Bieber>python
    ActivePython 2.4.3 Build 12 (ActiveState Software Inc.) based on
    Python 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>


    --
    Wulfraed Dennis Lee Bieber KD6MOG

    HTTP://wlfraed.home.netcom.com/
    (Bestiaria Support Staff: )
    HTTP://www.bestiaria.com/
     
    Dennis Lee Bieber, Sep 3, 2006
    #8
  9. mistral

    Jason Guest

    mistral wrote:
    > I have installed ActivePython
    > http://www.activestate.com/Products/ActivePython/
    > How I can run Python file, test.py?


    You can open up the folder containing the "test.py" file, then
    double-click on the file to run it. A command-line window should pop
    up, and your program will run in it. Once the Python program is done
    running, the command window will probably close immediately.

    --Jason
     
    Jason, Sep 3, 2006
    #9
  10. mistral

    Steve Holden Guest

    mistral wrote:
    > I have installed ActivePython
    > http://www.activestate.com/Products/ActivePython/
    > How I can run Python file, test.py?
    >

    Sheesh, you must have had ten replies and nobody bothered to point you
    to the frequently-asked questions ... kids today!

    http://www.python.org/doc/faq/windows.html

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://holdenweb.blogspot.com
    Recent Ramblings http://del.icio.us/steve.holden
     
    Steve Holden, Sep 3, 2006
    #10
  11. mistral

    mistral Guest

    Steve Holden пиÑал(а):

    > mistral wrote:
    > > I have installed ActivePython
    > > http://www.activestate.com/Products/ActivePython/
    > > How I can run Python file, test.py?


    > Sheesh, you must have had ten replies and nobody bothered to point you
    > to the frequently-asked questions ... kids today!


    > http://www.python.org/doc/faq/windows.html


    > regards
    > Steve
    > --
    > Steve Holden +44 150 684 7255 +1 800 494 3119
    > Holden Web LLC/Ltd http://www.holdenweb.com
    > Skype: holdenweb http://holdenweb.blogspot.com
    > Recent Ramblings http://del.icio.us/steve.holden

    -----------

    Really, looks its clear and straightforward Python FAQ.

    thanks.
     
    mistral, Sep 3, 2006
    #11
  12. mistral

    Guest

    mistral:
    > I have installed ActivePython
    > http://www.activestate.com/Products/ActivePython/
    > How I can run Python file, test.py?


    Running Python scripts is easy. Load the test.py from the ActivePython
    and run it.
    Otherwise you can just click on the file, otherwise you can open a
    shell in the dir where your py file is, and you can enter its name (so
    you can see its textual output). Tell us what happens and
    errors/problems you have.

    Bye,
    bearophile
     
    , Sep 3, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. se7en
    Replies:
    2
    Views:
    666
    Dave Kuhlman
    Feb 5, 2004
  2. Replies:
    3
    Views:
    360
    Gabriel Genellina
    Jun 23, 2007
  3. Seid Mohammed
    Replies:
    1
    Views:
    3,389
  4. Seid Mohammed
    Replies:
    0
    Views:
    395
    Seid Mohammed
    Nov 21, 2008
  5. Replies:
    9
    Views:
    995
    Paddy O'Loughlin
    Feb 27, 2009
Loading...

Share This Page