Python3Script Xojo Plugin |
|
Python3Script.SetPythonPath Method
Sets alternate path where to look for Python.
shared SetPythonPath(
path
as FolderItem)
Parameters
- path
- The full path to the actual Python 3.4.x or 3.5.x library.
Remarks
This method can only be set before calling Python3Script.Init after that time then this method will do nothing.
When setting the path it expects the full path to the actual Library as shown in the example bellow.
Note that if pointing to something that is not compatible, such as DLL that is not Python, DLL that is not one of the supported versions, 64 bit DLL from 32 bit application and other such will most likely result in crash.
Example:
Dim customPython as FolderItem
#if TargetMacOS
// Code to force use of 3.4 instead of 3.5
//customPython = GetFolderItem("/Library/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4.dylib", FolderItem.PathTypeNative)
// Example linking to Anaconda installation
// Note that as far as we know then there is only 64 bit version of Anaconda on OS X so dont try this on 32 bit application.
customPython = GetFolderItem("/Users/bjorneiriksson/anaconda/lib/libpython3.5m.dylib", FolderItem.PathTypeNative)
#elseif TargetWindows
// Example linking to Anaconda installation
customPython = GetFolderItem("C:\Anaconda3\python35.dll", FolderItem.PathTypeNative)
#else
// In this example then we are just using the default one on Linux
customPython = GetFolderItem("/home/bjorneiriksson/anaconda3/lib/libpython3.5m.so", FolderItem.PathTypeNative)
#endif
if customPython = nil or not customPython.Exists then
// The custom installation could not be found so we just fall back to default one
MsgBox "Could not find custom path, will try default installation"
elseif customPython.Exists then
Python3Script.SetPythonPath(customPython)
If not Python3Script.PythonIsFound() then
// The custom installation could not be loaded so we just fall back to default one
MsgBox "Could load custom path, will try default installation"
Python3Script.SetPythonPath(nil)
end if
end if
If not Python3Script.PythonIsFound() then
// If we still cannot find Python then it is probably not installed.
MsgBox "Correct Python installation was not found on this machine"
Quit()
else
Python3Script.Init("TestApp")
end if
See Also
Python3Script Class