Search code examples
windows-vistapath

Why can't I invoke python from the command line?


I have Python 2.6 installed on Windows Vista. If I am at C:\Python26> and I type python, Python's command-line interface starts, as desired.

I have added C:\Python26 to my PATH so that I would be able to run Python scripts from any directory, but it hasn't helped. In particular, from any other directory, the command python is not recognized.

I appreciate any guesses as to what change would get this working.

Edit: First, I have re-opened my cmd window (several times) so that is not the issue.

To clarify how I added C:\Python26 to the PATH, I clicked the following:

Computer -> System Properties -> Advanced system settings -> Environment Variables

at the point I select PATH and click Edit. I added C:\Python26 to the Variable Value field, separating this from the previous entries with a semicolon. Then I click OK a few times.

Edit #2 I've now checked my PATH by typing path at the command prompt. C:\Python26 is certainly in the path. I'll reboot anyway, and see if that helps.


Solution

  • This still sounds like a path issue.

    If you have just added c:\Python26 to your path, then you need to open a new cmd window before those changes take effect, they won't apply to your existing cmd windows.

    If you're unsure how to do this in Windows Vista, here is the instructions.

    1. Select Settings -> Control Panel from the start menu.
    2. Double click the 'System' icon.
    3. Choose 'Advanced System Settings' on the left hand side.
    4. Choose 'Environment Variables'
    5. In the bottom list, select 'Path', and click 'Edit...'
    6. At the end of the path string, add ;C:\Python26, leaving everything else the same, then click OK, then click OK again on the various windows still open.

    Now open a new cmd window, and try the 'python' command from any directory - it should work.

    This may be obvious to most people, but hopefully anyone with the same problem will find the help they need in this answer.