如何使用 Python 脚本 运行 a Windows .exe 在 conda 环境中 link 到 .dll?

How to link to .dlls in conda environment using a Python Script running a Windows .exe?

我正在使用一个脚本来填充具有自定义功能的 Structure-from-Motion 软件 COLMAP。 此脚本通常为 linux 分发,我不得不在 Windows 10.

中进行一些改编

脚本通过以下方式调用 COLMAP:

cmd = [
        str(colmap_path), 'feature_importer',
        '--database_path', str(database_path),
        '--image_path', str(image_dir),
        '--import_path', str(dummy_dir),
        '--ImageReader.single_camera',
        str(int(single_camera))]
    ret = subprocess.call(cmd)
    if ret != 0:
        logging.warning('Problem with feature_importer, exiting.')
        exit(ret)

对于 colmap_path 我 linked 到 colmap.exe 并且它被执行但缺少存储在单独文件夹中的 .dll。程序结构如下:

我的尝试是将 .dll 文件复制到 /anaconda3/envs/my_env,但随后出现错误:

qt.qpa.plugin: Could not find the Qt platform plugin "windows" in "" This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

那么是否可以直接link到ret = subprocess.call(cmd)中的.dll和平台?

我在另一个 website 上找到了解决方案。我必须将包含 qwindows.dll 的平台文件夹复制到 bin 文件夹中。这可以作为许多不同的可执行 .exe 应用程序的解决方案; subprocess.call 然后能够毫无错误地找到 qt 平台插件和脚本 运行。