[Python.NET] avoiding runtime error R6034

Cameron Hayne <cameron.hayne-/[email protected]>
Newsgroups gmane.comp.python.dotnet
Message-ID <[email protected]>
I’ve started using the version of PythonDotNet from https://github.com/renshawbay/pythonnet
to call my Python modules from C#.
I encountered the Microsoft runtime error R6034 which
(according to <http://stackoverflow.com/questions/14552348/runtime-error-r6034-in-embedded-python-application>)
is caused by extra copies of the file "msvcr90.dll” in folders on the Windows execution PATH.
I worked around this problem by calling the following function in my initialization code.

def cleanWindowsPathOfCRuntimeDll():
    """
    This function changes the Windows execution PATH environment variable
    so as to exclude any folders that contain the file "msvcr90.dll".
    Apparently the existence of this file in the PATH causes runtime error R6034
    when using embedded Python.
    See: http://stackoverflow.com/questions/14552348/runtime-error-r6034-in-embedded-python-application
    """
    folderPaths = os.environ['path'].split(';')
    toExclude = list()
    for folderPath in folderPaths:
        if "msvcr90.dll" in map((lambda x:x.lower()), os.listdir(folderPath)):
            toExclude.append(folderPath)
            debugMsg(0, "excluding folder '%s' from PATH" % folderPath)
    os.environ['path'] = ';'.join([x for x in folderPaths
                                              if x not in toExclude])
# ——————————————————————————————————————

--
Cameron Hayne
cameron.hayne-/[email protected]



_________________________________________________
Python.NET mailing list - [email protected]
https://mail.python.org/mailman/listinfo/pythondotnet
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.