简体   繁体   English

Python 找不到要导入的模块

[英]Python can't find module for import

I have a dll file that I need to import in Python.我有一个 dll 文件,我需要在 Python 中导入该文件。 However when I try to load the assembly I get the error:但是,当我尝试加载程序集时,出现错误:

ModuleNotFoundError: No module named 'TEST_NET' ModuleNotFoundError:没有名为“TEST_NET”的模块

The assembly dll file is located in C:\Program Files\TEST APP\APP 7.0 under the name TEST_NET.Core.dll程序集 dll 文件位于名称TEST_NET.Core.dll下的C:\Program Files\TEST APP\APP 7.0

My code is the following:我的代码如下:

app_version = "7.0"
app_library = "C:\Program Files\TEST APP\APP 7.0"

# load app assemblies... replace the path below with the installation
#   installation folder for your app installation.
# Import from .NET assemblies (both App and system)
sys.path.append(app_library)
clr.AddReference('TEST_NET.Core')
from TEST_NET.Core import*

The code was working well with a previous app version.该代码在以前的应用程序版本中运行良好。 But the new app that contains the file has return this issue where the module is not found when trying to import.但是包含该文件的新应用程序已返回此问题,即尝试导入时找不到模块。 Any idea what might be wrong here?知道这里可能有什么问题吗?

Thanks!谢谢!

use ctypes to import a dll使用 ctypes 导入 dll

import ctypes

dll = ctypes.WinDLL (r"C:\Program Files\TEST APP\APP 7.0\TEST_NET.Core.dll")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM