You know what has worked for me really well on windows.
My Computer > Properties > Advanced System Settings > Environment Variables >
Just add the path as C:\Python27 (or wherever you installed python)
OR
Then under system variables I create a new Variable called PythonPath. In this variable I have C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\other-folders-on-the-path

This is the best way that has worked for me which I hadn't found in any of the docs offered.
EDIT: For those who are not able to get it, Please add
C:\Python27;
along with it. Else it will never work.
Answer from darren on Stack OverflowYou know what has worked for me really well on windows.
My Computer > Properties > Advanced System Settings > Environment Variables >
Just add the path as C:\Python27 (or wherever you installed python)
OR
Then under system variables I create a new Variable called PythonPath. In this variable I have C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\other-folders-on-the-path

This is the best way that has worked for me which I hadn't found in any of the docs offered.
EDIT: For those who are not able to get it, Please add
C:\Python27;
along with it. Else it will never work.
Windows 7 Professional I Modified @mongoose_za's answer to make it easier to change the python version:
- [Right Click]Computer > Properties >Advanced System Settings > Environment Variables
- Click [New] under "System Variable"
- Variable Name: PY_HOME, Variable Value:C:\path\to\python\version

- Click [OK]
- Locate the "Path" System variable and click [Edit]
Add the following to the existing variable:
%PY_HOME%;%PY_HOME%\Lib;%PY_HOME%\DLLs;%PY_HOME%\Lib\lib-tk;

Click [OK] to close all of the windows.
As a final sanity check open a command prompt and enter python. You should see
>python [whatever version you are using]
If you need to switch between versions, you only need to modify the PY_HOME variable to point to the proper directory. This is bit easier to manage if you need multiple python versions installed.
Python and the PATH variable in Windows 10
python - Permanently add a directory to PYTHONPATH? - Stack Overflow
How to add python to path and how to use it in commandline/powershell?
How to add my project folder to the PYTHONPATH?
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.
Do you remember checking the box in the image shown below to add your Python installation to PATH in Windows 10?
Adding Python to PATHWell, I was curious! What if someone accidentally forgot to check that little radio button? What would be the possible recovery steps?
So I spent my evening yesterday uninstalling Python and re-installing to figure out a way to add Python to the PATH post-installation.
If you forget to add Python to the PATH variable, you won't be able to run Python in your command line.
You will get a message saying,
‘python' is not recognized as an internal or external command.
Here are the steps I used 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. 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".
I found out that if you paste the path at the end, it still doesn't work. Can someone tell me why?
Anyways, if the steps are not clear to anyone, here is a visual guide containing images of every step, on my blog for achieving the above objective. If you are interested, do take a look.
If you're using bash (on a Mac or GNU/Linux distro), add this to your ~/.bashrc
export PYTHONPATH="${PYTHONPATH}:/my/other/path"
You need to add your new directory to the environment variable PYTHONPATH, separated by a colon from previous contents thereof. In any form of Unix, you can do that in a startup script appropriate to whatever shell you're using (.profile or whatever, depending on your favorite shell) with a command which, again, depends on the shell in question; in Windows, you can do it through the system GUI for the purpose.
superuser.com may be a better place to ask further, i.e. for more details if you need specifics about how to enrich an environment variable in your chosen platform and shell, since it's not really a programming question per se.
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?
I am using a scheduler app that requires the full path of my project.pythonfile.method to run the method that needs to be scheduled.
But it is not working.
I noticed even from project.pythonfile import method is not found. I never needed that as I am using relative paths until now (from .pythonfile import method). But as my scheduler is a third party app, I don't think it will work.
I did some research and I think I need to append my project folder to the PYTHON PATH variable. Does anyone know how to do that? is there a GUI in the Windows interface? or is it all command based?
I assume it is different from the OS Environment PATH variable? or no?
I am using Windows btw.