Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 508267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:53:22+00:00 2026-05-13T06:53:22+00:00

I have a simple script blah.py (using Python 2): import sys print sys.argv[1] If

  • 0

I have a simple script blah.py (using Python 2):

import sys
print sys.argv[1]

If I execute my script by:

python c:/..../blah.py argument

It prints argument but if I execute script by:

blah.py argument

error occurs:

IndexError…

So arguments do not pass to script.

python.exe in PATH. Folder with blah.py also in PATH.
python.exe is default program to execute *.py files.

What is the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:53:23+00:00Added an answer on May 13, 2026 at 6:53 am

    When you execute a script without typing “python” in front, you need to know two things about how Windows invokes the program. First is to find out what kind of file Windows thinks it is:

        C:\>assoc .py
        .py=Python.File
    

    Next, you need to know how Windows is executing things with that extension. It’s associated with the file type “Python.File”, so this command shows what it will be doing:

        C:\>ftype Python.File
        Python.File="c:\python26\python.exe" "%1" %*
    

    So on my machine, when I type “blah.py foo”, it will execute this exact command, with no difference in results than if I had typed the full thing myself:

        "c:\python26\python.exe" "blah.py" foo
    

    If you type the same thing, including the quotation marks, then you’ll get results identical to when you just type “blah.py foo”. Now you’re in a position to figure out the rest of your problem for yourself.

    (Or post more helpful information in your question, like actual cut-and-paste copies of what you see in the console. Note that people who do that type of thing get their questions voted up, and they get reputation points, and more people are likely to help them with good answers.)

    Brought In From Comments:

    Even if assoc and ftype display the correct information, it may happen that the arguments are stripped off. What may help in that case is directly fixing the relevant registry keys for Python. Set the

    HKEY_CLASSES_ROOT\Applications\python26.exe\shell\open\command
    

    key to:

    "C:\Python26\python26.exe" "%1" %*
    

    Likely, previously, %* was missing. Similarly, set

     HKEY_CLASSES_ROOT\py_auto_file\shell\open\command
    

    to the same value. See http://eli.thegreenplace.net/2010/12/14/problem-passing-arguments-to-python-scripts-on-windows/

    example registry setting for python.exe
    HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command The registry path may vary, use python26.exe or python.exe or whichever is already in the registry.

    enter image description here
    HKEY_CLASSES_ROOT\py_auto_file\shell\open\command

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple python script, 'first.py': #first.py def firstFunctionEver() : print hello firstFunctionEver() I
I have simple Python script to execute test suite both under Windows and Linux.
I have a simple Python script that I want to stop executing if a
I have a simple php script on a server that's using fsockopen to connect
I have a simple script that will send out a bunch of emails but
I have a simple script I'm trying to run: <?php print exec('whoami'); $output2 =
I have a simple python script that just takes in a filename, and spits
I have a simple script which is used to start another program. This other
I have a simple script that does some search and replace. This is basically
I have a simple linux script: #!/bin/sh for i in `ls $1` do echo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.