- Hold Win and press Pause.
- Click Advanced System Settings.
- Click Environment Variables.
- Append
;C:\python27to thePathvariable. - Restart Command Prompt.
- Hold Win and press Pause.
- Click Advanced System Settings.
- Click Environment Variables.
- Append
;C:\python27to thePathvariable. - Restart Command Prompt.
When setting Environmental Variables in Windows, I have gone wrong on many, many occasions. I thought I should share a few of my past mistakes here hoping that it might help someone. (These apply to all Environmental Variables, not just when setting Python Path)
Watch out for these possible mistakes:
- Kill and reopen your shell window: Once you make a change to the ENVIRONMENTAL Variables, you have to restart the window you are testing it on.
- NO SPACES when setting the Variables. Make sure that you are adding the
;C:\Python27WITHOUT any spaces. (It is common to tryC:\SomeOther; C:\Python27That space (␣) after the semicolon is not okay.) - USE A BACKWARD SLASH when spelling out your full path. You will see forward slashes when you try
echo $PATHbut only backward slashes have worked for me. - DO NOT ADD a final backslash. Only
C:\Python27NOTC:\Python27\
So the answer I've been getting is add python to environment variables which I have done
But I still get the error when running from user/downloads
python -c "from pdf2docx import Converter"
The system cannot execute the specified program.
p.s why are we banning images makes things so much more complicated?
Python Installation
Why doesnt Python add itself to PATH on Windows?
Python not found by command prompt
What if you forget to add Python to PATH?
Videos
For Windows 10/8/7:
- Open
System Properties(Right clickComputerin the start menu, or use the keyboard shortcut Win+Pause) - Click
Advanced system settingsin the sidebar. - Click
Environment Variables... - Select
PATHin theSystem variablessection - Click
Edit Add Python's path to the end of the list (the paths are separated by semicolons). For example:
C:\Windows;C:\Windows\System32;C:\Python27
For Windows XP:
- Open
System Properties(Type it in the start menu, or use the keyboard shortcut Win+Pause) - Switch to the
Advancedtab - Click
Environment Variables... - Select
PATHin theSystem variablessection - Click
Edit Add Python's path to the end of the list (the paths are separated by semicolons). For example:
C:\Windows;C:\Windows\System32;C:\Python27Test on a new terminal window or if using an integrated terminal within a text editor, close and restart your editor or the changes won't be applied.
For anyone trying to achieve this with Python 3.3+, the Windows installer now includes an option to add python.exe to the system search path. Read more in the docs.
Is there any reason why that checkbox to add to PATH unchecked by default on Windows? Pretty much any programs you install that can have a cli frontend add to PATH by default and nobody complains.
Just having that checkbox checked by default would help many new to programming people. I mean, sure put that option in the front incase someone does not want to add python to PATH.
Is there any reason it is done that way I am unfamiliar with?
If you forget to add Python to the PATH, you won't be able to run Python in your command line from any other directory.
You will get a message saying,
'python' is not recognized as an internal or external command.
This is because Windows is trying to search for Python in its PATH variable and is unable to find it.
Here is a step-by-step instruction to add Python to the PATH variable in Windows 10.
-
Copy the directory to which Python is being installed.
-
Search for System Properties in the Search Bar.
-
Click on the "Environment Variables" button in System Properties.
-
Click on the "Path" variable and then click on "Edit".
-
Now here's the deal. Pay Attention! Paste the directory path from Step 1 at the top of the list. You can use the "Move up" button to get it to the top. Now click on "Ok".
Now you can open up your command line and run python. The Python interactive shell will open up.
*Here is a little extra tip! *
Add the Scripts folder to the PATH variable too. This is the folder where all your libraries will be installed.
If the instructions are not clear enough for you, you can also check out the visual guide containing images of every step, on my blog for achieving the above objective.
Good luck and let me know!