running python from cmd.exe

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dominic Rice

    running python from cmd.exe

    Hi,

    I can't seem to get python to run my scripts using the command: python
    <userscript>. py

    If I type python the interpreter runs as I sorted out the Path property,

    I'm afraid I don't know much about this kind of thing as I'm a science
    student who needs some Python not a programmer!

    Thanks in advance
  • Miki

    #2
    Re: running python from cmd.exe

    Hello,
    I can't seem to get python to run my scripts using the command: python
    <userscript>. py
    >
    If I type python the interpreter runs as I sorted out the Path property,
    >
    I'm afraid I don't know much about this kind of thing as I'm a science
    student who needs some Python not a programmer!
    Can you be more specific about the error you get?

    Say you have a script hw.py that contains one line:
    print "Hello Python"

    and you run
    python hw.py

    What is the error you get?

    HTH,
    --
    Miki <miki.tebeka@gm ail.com>
    If it won't be simple, it simply won't be. [Hire me, source code]


    Comment

    • Dominic Rice

      #3
      Re: running python from cmd.exe

      Miki wrote:
      Hello,
      >
      >I can't seem to get python to run my scripts using the command: python
      ><userscript>.p y
      >>
      >If I type python the interpreter runs as I sorted out the Path property,
      >>
      >I'm afraid I don't know much about this kind of thing as I'm a science
      >student who needs some Python not a programmer!
      Can you be more specific about the error you get?
      >
      Say you have a script hw.py that contains one line:
      print "Hello Python"
      >
      and you run
      python hw.py
      >
      What is the error you get?
      >
      HTH,
      --
      Miki <miki.tebeka@gm ail.com>
      If it won't be simple, it simply won't be. [Hire me, source code]

      >
      Sure, I get:

      can't open file <userscript>.py : [errorno 2]No such file or directory.

      Now if I've noticed that if I change directory to (for instance)
      \Python25 where the script is the command runs fine.(?)

      Comment

      • Dominic Rice

        #4
        Re: running python from cmd.exe

        Dominic Rice wrote:
        Miki wrote:
        >Hello,
        >>
        >>I can't seem to get python to run my scripts using the command: python
        >><userscript>. py
        >>>
        >>If I type python the interpreter runs as I sorted out the Path property,
        >>>
        >>I'm afraid I don't know much about this kind of thing as I'm a science
        >>student who needs some Python not a programmer!
        >Can you be more specific about the error you get?
        >>
        >Say you have a script hw.py that contains one line:
        >print "Hello Python"
        >>
        >and you run
        >python hw.py
        >>
        >What is the error you get?
        >>
        >HTH,
        >--
        >Miki <miki.tebeka@gm ail.com>
        >http://pythonwise.blogspot.com
        >>
        Sure, I get:
        >
        can't open file <userscript>.py : [errorno 2]No such file or directory.
        >
        Now if I've noticed that if I change directory to (for instance)
        \Python25 where the script is the command runs fine.(?)
        Oh I just noticed you specified hw.py, in that case just to clarify it
        would be can't open file hw.py: [errorno 2]No such file or directory

        Comment

        • Chris Hulan

          #5
          Re: running python from cmd.exe

          On Jul 4, 5:38 am, Dominic Rice <dominic.r...@g mail.comwrote:
          Dominic Rice wrote:
          Miki wrote:
          Hello,
          >
          >I can't seem to get python to run my scripts using the command: python
          ><userscript>.p y
          >
          >If I type python the interpreter runs as I sorted out the Path property,
          >
          >I'm afraid I don't know much about this kind of thing as I'm a science
          >student who needs some Python not a programmer!
          Can you be more specific about the error you get?
          >
          Say you have a script hw.py that contains one line:
          print "Hello Python"
          >
          and you run
          python hw.py
          >
          What is the error you get?
          >
          HTH,
          --
          Miki <miki.teb...@gm ail.com>
          >http://pythonwise.blogspot.com
          >
          Sure, I get:
          >
          can't open file <userscript>.py : [errorno 2]No such file or directory.
          >
          Now if I've noticed that if I change directory to (for instance)
          \Python25 where the script is the command runs fine.(?)
          >
          Oh I just noticed you specified hw.py, in that case just to clarify it
          would be can't open file hw.py: [errorno 2]No such file or directory
          When you run a script, are you in the directory where the script is
          located?

          Comment

          • Dominic Rice

            #6
            Re: running python from cmd.exe

            Chris Hulan wrote:
            On Jul 4, 5:38 am, Dominic Rice <dominic.r...@g mail.comwrote:
            >Dominic Rice wrote:
            >>Miki wrote:
            >>>Hello,
            >>>>I can't seem to get python to run my scripts using the command: python
            >>>><userscript >.py
            >>>>If I type python the interpreter runs as I sorted out the Path property,
            >>>>I'm afraid I don't know much about this kind of thing as I'm a science
            >>>>student who needs some Python not a programmer!
            >>>Can you be more specific about the error you get?
            >>>Say you have a script hw.py that contains one line:
            >>>print "Hello Python"
            >>>and you run
            >>>python hw.py
            >>>What is the error you get?
            >>>HTH,
            >>>--
            >>>Miki <miki.teb...@gm ail.com>
            >>>http://pythonwise.blogspot.com
            >>Sure, I get:
            >>can't open file <userscript>.py : [errorno 2]No such file or directory.
            >>Now if I've noticed that if I change directory to (for instance)
            >>\Python25 where the script is the command runs fine.(?)
            >Oh I just noticed you specified hw.py, in that case just to clarify it
            >would be can't open file hw.py: [errorno 2]No such file or directory
            >
            When you run a script, are you in the directory where the script is
            located?
            when it works yes! Does it have to be the case then? I assumed that
            there was a default folder (eg \Python25) that the python command would
            look for the file in, I take it this is not the case then?

            Comment

            • John Machin

              #7
              Re: running python from cmd.exe

              On Jul 5, 7:38 am, Dominic Rice <dominic.r...@g mail.comwrote:
              Chris Hulan wrote:
              On Jul 4, 5:38 am, Dominic Rice <dominic.r...@g mail.comwrote:
              Dominic Rice wrote:
              >Miki wrote:
              >>Hello,
              >>>I can't seem to get python to run my scripts using the command: python
              >>><userscript> .py
              >>>If I type python the interpreter runs as I sorted out the Path property,
              >>>I'm afraid I don't know much about this kind of thing as I'm a science
              >>>student who needs some Python not a programmer!
              >>Can you be more specific about the error you get?
              >>Say you have a script hw.py that contains one line:
              >>print "Hello Python"
              >>and you run
              >>python hw.py
              >>What is the error you get?
              >>HTH,
              >>--
              >>Miki <miki.teb...@gm ail.com>
              >>>http://pythonwise.blogspot.com
              >Sure, I get:
              >can't open file <userscript>.py : [errorno 2]No such file or directory.
              >Now if I've noticed that if I change directory to (for instance)
              >\Python25 where the script is the command runs fine.(?)
              Oh I just noticed you specified hw.py, in that case just to clarify it
              would be can't open file hw.py: [errorno 2]No such file or directory
              >
              When you run a script, are you in the directory where the script is
              located?
              >
              when it works yes! Does it have to be the case then? I assumed that
              there was a default folder (eg \Python25) that the python command would
              look for the file in, I take it this is not the case then?
              The default folder *is* the "current" folder, i.e. "the directory that
              you are in". If you want to run a script in another folder, you
              specify the path to that script. This is usual in Windows command-line
              operation, not special to Python.

              By the way, storing your own files in the same folder structure as a
              software package (e.g. \Python25) is not a good idea. Keep them
              somewhere else e.g. a separate folder for each significantly different
              project, a folder for commonly useful stuff, and a junk folder for
              mucking about trying things out. Then when e.g. you upgrade to Python
              2.6 the possibility of drama is reduced.

              HTH,
              John

              Comment

              • Dominic Rice

                #8
                Re: running python from cmd.exe

                John Machin wrote:
                On Jul 5, 7:38 am, Dominic Rice <dominic.r...@g mail.comwrote:
                >Chris Hulan wrote:
                >>On Jul 4, 5:38 am, Dominic Rice <dominic.r...@g mail.comwrote:
                >>>Dominic Rice wrote:
                >>>>Miki wrote:
                >>>>>Hello,
                >>>>>>I can't seem to get python to run my scripts using the command: python
                >>>>>><userscri pt>.py
                >>>>>>If I type python the interpreter runs as I sorted out the Path property,
                >>>>>>I'm afraid I don't know much about this kind of thing as I'm a science
                >>>>>>student who needs some Python not a programmer!
                >>>>>Can you be more specific about the error you get?
                >>>>>Say you have a script hw.py that contains one line:
                >>>>>print "Hello Python"
                >>>>>and you run
                >>>>>python hw.py
                >>>>>What is the error you get?
                >>>>>HTH,
                >>>>>--
                >>>>>Miki <miki.teb...@gm ail.com>
                >>>>>http://pythonwise.blogspot.com
                >>>>Sure, I get:
                >>>>can't open file <userscript>.py : [errorno 2]No such file or directory.
                >>>>Now if I've noticed that if I change directory to (for instance)
                >>>>\Python25 where the script is the command runs fine.(?)
                >>>Oh I just noticed you specified hw.py, in that case just to clarify it
                >>>would be can't open file hw.py: [errorno 2]No such file or directory
                >>When you run a script, are you in the directory where the script is
                >>located?
                >when it works yes! Does it have to be the case then? I assumed that
                >there was a default folder (eg \Python25) that the python command would
                >look for the file in, I take it this is not the case then?
                >
                The default folder *is* the "current" folder, i.e. "the directory that
                you are in". If you want to run a script in another folder, you
                specify the path to that script. This is usual in Windows command-line
                operation, not special to Python.
                >
                By the way, storing your own files in the same folder structure as a
                software package (e.g. \Python25) is not a good idea. Keep them
                somewhere else e.g. a separate folder for each significantly different
                project, a folder for commonly useful stuff, and a junk folder for
                mucking about trying things out. Then when e.g. you upgrade to Python
                2.6 the possibility of drama is reduced.
                >
                HTH,
                John
                seems like very good advice, many thanks!

                Comment

                Working...