我的小程序import clr
崩溃了.exe
。
以下是我在程序中使用的导入:
import sys
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from PyQt4.QtGui import QApplication, QMainWindow
from PyQt4.Qt import QGridLayout, QWidget
import clr
executablePath = 'E:\\PythonWS\\MyDll\\'
sys.path.append(executablePath)
clr.AddReference("MyDll")
import MyDll
基本上程序编译得很好,并且由于cx_freeze我得到了一个可执行文件,但是当我使用日志启动它时,它会崩溃import clr
如果有人有想法,我不知道该怎么做才能使它工作?
编辑:
我添加了一个try-except,import clr
如下所示:
try:
logger.info('in try')
import clr
executablePath = 'E:\\PythonWS\\MyDll\\'
sys.path.append(executablePath)
clr.AddReference("MyDll")
dllPath = clr.FindAssembly('MyDll')
import MyDll
ts = MyDll.TestSystem('127.0.0.1', '127.0.0.1')
print ts.mainBoard.isConnected()
except Exception as e:
logger.info("Unexpected error: {}".format(e))
但即使try
应用程序崩溃......这让我有两个选择,
- 要么我
try
except
的不好,然后为什么? - 有一个真正的问题,
clr
我需要帮助。
编辑2:
我尝试导入其他模块,这些模块.pyd
可能是因为.exe
找不到它们,但import
我尝试过的所有操作都没有任何问题。
编辑3:
所以!在查看其他帖子后,我发现还有其他导入 dll 的方法:ctypes
例如使用。
问题是:我的 dll 在C#
并且显然导入不是很好地支持ctypes
......我遇到了类似的错误WindowsError: [Error -532462766] Windows Error 0xE0434352
,这对我没有多大帮助,因为它似乎是 Windows 中的一个非常普遍的错误,但这让我觉得可能是事情这使我的程序在导入 clr 时崩溃是一样的。有谁知道该错误与什么有关?
所以我回到使用 .NET clr
,但仍然没有运气
作为记录:我已经尝试过 python 32 位和 64 位。这里有更多信息
#with python 32 bits
platform architecture: ('32bit', 'WindowsPE')
sys.platform: win32
os.name: nt
#with python 64 bits
platform architecture: ('64bit', 'WindowsPE')
sys.platform: win32
os.name: nt