Running a Python Script via PuTTY

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mott3510
    New Member
    • Jul 2009
    • 22

    Running a Python Script via PuTTY

    I wrote a python script and I have copied my file (verification.p y) into my http directory. However, when I try to run the script I get many errors...

    Code:
    ..
    : No such file or directoryline 1: #!/usr/bin/python
    : command not foundect.py: line 3:
    ./Verification_Project.py: line 4: from: command not found
    : command not foundect.py: line 5:
    ./Verification_Project.py: line 6: from: command not found
    import: unable to open X server `'.
    import: unable to open X server `'.
    import: unable to open X server `'.
    import: unable to open X server `'.
    import: unable to open X server `'.
    import: unable to open X server `'.
    import: unable to open X server `'.
    import: unable to open X server `'.
    ./Verification_Project.py: line 15: from: command not found
    import: unable to open X server `'.
    : command not foundect.py: line 19:
    ./Verification_Project.py: line 20: syntax error near unexpected token `('
    '/Verification_Project.py: line 20: `today = datetime.date.today()
    ..
    I am not sure why I am getting these errors because when I run the script in Python it works fine.

    Thanks!
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    At the command line, did you type in:
    python path/verification.py
    ??

    Comment

    • mott3510
      New Member
      • Jul 2009
      • 22

      #3
      Initially, no I did not, I typed ./Verification.py
      However, I just tried that from my http directory which is where the file is located and it said

      python: can't open file 'path/Verification_Pr oject.py': [Errno 2] No such file or directory

      Comment

      • bvdet
        Recognized Expert Specialist
        • Oct 2006
        • 2851

        #4
        From your HTTP directory, try typing in python Verification.py. When I posted python path/Verification.py, I did not mean path literally, but the actual path to your file on your system. You may also need the path to the python interpreter.

        Comment

        • mott3510
          New Member
          • Jul 2009
          • 22

          #5
          I wrote my python script in windows, however I need to convert it so that it will run on a linux computer. Do you know how I would convert from windows to linux?

          Comment

          • bvdet
            Recognized Expert Specialist
            • Oct 2006
            • 2851

            #6
            Most Python code is not platform dependent. PuTTY is available for Windows and Unix platforms.

            -BV

            Comment

            • Arun Raja V J
              New Member
              • Oct 2014
              • 1

              #7
              There are two ways to doing it.
              Method 1
              First make the script executable
              chmod u+x <script>.py
              ./<script>.py

              Method 2
              Python -v <script>.py

              Comment

              Working...