Runtime error R6034 in embedded Python application

2019-01-16 06:57发布

I am working on an application which uses Boost.Python to embed the Python interpreter. This is used to run user-generated "scripts" which interact with the main program.

Unfortunately, one user is reporting runtime error R6034 when he tries to run a script. The main program starts up fine, but I think the problem may be occurring when python27.dll is loaded.

I am using Visual Studio 2005, Python 2.7, and Boost.Python 1.46.1. The problem occurs only on one user's machine. I've dealt with manifest issues before, and managed to resolve them, but in this case I'm at a bit of a loss.

Has anyone else run into a similar problem? Were you able to solve it? How?

12条回答
我命由我不由天
2楼-- · 2019-01-16 07:02

Thanks for the solution. I just little modified this sample code as the path variable in my system contains the string "ICLS CLIENT" instead of "iCLS Client"

import os
# print os.environ['PATH']
# Remove CLS Client from system path
if os.environ['PATH'].find("iCLS Client") >= 0 or os.environ['PATH'].find("ICLS CLIENT") >= 0:
    os.environ['PATH'] = "".join([it for it in os.environ['PATH'].split(";") if not (it.find("iCLS Client")>0 or it.find("ICLS CLIENT")>0)])
查看更多
在下西门庆
3楼-- · 2019-01-16 07:05

This post elaborates on @Micheal Cooper and @frmdstryr. Once you identified the problematic PATH entries, you can put the following in front of a python script, assuming here that iCLS Client and CMake are problematic.

import os
for forbidden_substring in ['iCLS Client', 'CMake']:
    os.environ['PATH'] = ';'.join([item for item in os.environ['PATH'].split(';')
                                   if not item.lower().find(forbidden_substring.lower()) >= 0])

Concerning the vim with YouCompleteMe case, you can put the following at the top of your vimrc:

python << EOF
import os
for forbidden_substring in ['iCLS Client', 'CMake']:
    os.environ['PATH'] = ';'.join([item for item in os.environ['PATH'].split(';')
                                   if not item.lower().find(forbidden_substring.lower()) >= 0])
EOF

If none of these solutions is applicable for you, you can try to remove the problem causing entries from you PATH manually, but you want to make sure you don't break anything else on your system that depends on these PATH entries. So, for instance, for CMake you could try to remove its PATH entry, and only put a symlink (or the like) pointing to the cmake.exe binary into some other directory that is in your PATH, to make sure cmake is still runnable from anywhere.

查看更多
做自己的国王
4楼-- · 2019-01-16 07:09

In my case the rebuilding of linked libraries and the main project with similar "Runtime execution libraries" project setting helped. Hope that will be usefull for anybody.

查看更多
beautiful°
5楼-- · 2019-01-16 07:11

In my case, I realised the problem was coming when, after compiling the app into an exe file, I would rename that file. So leaving the original name of the exe file doesn't show the error.

查看更多
smile是对你的礼貌
6楼-- · 2019-01-16 07:12

I also had the same problem with embedding Python27.dll from a C-program using the Universal-CRT.

A <PYTHON_ROOT>\msvcr90.dll was the offender. And <PYTHON_ROOT> is off-course in my PATH. AFAICS the only users of msvcr90.dll are the PyWin32 modules <PYTHON_ROOT>\lib\site-packages\win32\win32*.pyd.

The fix was just move <PYTHON_ROOT>\msvcr90.dll to that directory.

PS. PyWin32 still has this as an issue 7 years later!

查看更多
对你真心纯属浪费
7楼-- · 2019-01-16 07:19

The discussion on this page involves doing things way far advanced above me. (I don't code.) Nevertheless, I ran Process Explorer as the recommended diagnostic. I found that another program uses and needs msvcr90.dll in it's program folder. Not understanding anything else being discussed here, as a wild guess I temporarily moved the dll to a neighboring program folder.

Problem solved. End of Runtime error message.

(I moved the dll back when I was finished with the program generating the error message.)

Thank you all for your help and ideas.

查看更多
登录 后发表回答