Most python users have multiple python versions installed. In addition various other software packages install custom versions of python often placing pythonxx.dll on the windows system path as defined by the environment variable %PATH%. It is worth explaining how PyScripter locates the python dll, since the issue pops up regularly in the newsgroup and submitted bug reports.
There are two types of Python installation:
- All users installation
Python creates registry entries with installation info at HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.x and puts places the python dll in c:\Windows\System32.
- Single user installation
Python creates registry entries with installation info at HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.x and does not put the dll in c:\Windows\System32.
PyScripter, without any command line flags looks at the registry to find the latest version of Python and then for an all user installation tries to load the relevant Python dll from the system path. For a single user installation tries to load the DLL from the Install path that is in the registry.
In more detail PyScripter does the following:
Currently PyScripter knows of versions 3.2, 3.1, 3.0, 2.7...2.3. Below, system path refers to the Windows path (environment variable) and x.x refers to the version number.
Repeat for versions 3.2 down to 2.3:
- Look at the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\x.x (All users). If key is found assume the dll is in the system path and try to load it.
- If the previous key does not exist it look at HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\x.x (Single user) and try to load the Python DLL from the path specified in the registry.
- If there is no info in the registry try to load the DLL from the system path to cater for unregistered Python versions.
- If Python DLL was loaded successfully then break
When PyScripter is used with a --PYTHONxx flag then it does the above but searching only for the specific version. The Registry lookup does not take place when Python is used with the --PYTHONDLLPATH. Instead PyScripter tries to load the Python dll from the specified path. The --PYTHONDLLPATH flag should be used with the --PYTHONxx flag. See http://pyscripter.googlepages.com/portablepython for an example of using PyScripter with portable Python.
The %PYTHONHOME% environment variable is not used by PyScripter directly but by Python to find the installed libraries. See the Python documentation for its use.