Is there a good way to determine at runtime which python versions are supported? · pythonnet/pythonnet · Discussion #1724
Often we have multiple versions of python installed, although not idea. For example, most often I find python 3.7 or 3.8 in parallel with 3.9.
When I'm using pythonnet 2.5.1 I would like to flag in my UI somehow that 3.9 is not supported, so I can react, like change some paths or switch the version to 3.7 or 3.8.
I would like to make a check, get all installed python versions, and a list of the supported ones by python.NET, to exclude the unsupported ones in my app.
Is there a good way to determine this at runtime?
4 replies
Thanks Victor!
Is there anything that can list, at runtime, the supported versions by python.NET?
My use case is that my app is an add-in and doesn't install python.NET itself, so I can't just hardcode a value.
One very hacky way I can think of is to try and find Python.Runtime.dll (relying on a relative path), and listing the generated namespaces TypeOffsetXY where X is the major version and Y is the minor version, for example TypeOffset37. But this is sort of a hacky way and very prone to errors.
Is there a good way of finding out what are the supported versions by python.NET, at runtime?
We could expose this as a property or function in the DLL (only for 3.0 onwards, I don't think we will make another 2.5 release).
Ok, good to know. And yes, I believe that would be a good thing to have going forward.
Thank you, Benedikt!