Tcl:如何改变nameofexecutab的行为

2024-05-12 12:57:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我对使用python解释器的c可执行文件中的tcl有一些问题。 由于某些原因,它无法加载<fullpath>Tix843.dll。但是当直接(从python)运行python代码时,它确实可以工作。dll的路径/名称正确。。。 我只看到Tkinter试图加载tixdll,但是找不到它。。。在

在跟踪了tcl中的所有路径之后,我只能检测到1个差异:nameofexecutable。当直接从python运行时,它是python.exe的路径,但是当从c可执行文件运行它时,它(显然)是path/name of the executable。在

在tcl/tk中,我注意到nameofexecutable用于设置许多路径,因此我认为这是我的问题所在。在

我试图阻止这个问题:

  1. 将dll的路径添加到系统路径
  2. 将dll的路径添加到$auto_path->;无更改
  3. 在调用PySys\u SetArgv->;no change之前,设置c可执行文件的argv[0]

我在做什么蠢事吗?或者我如何设置nameofexecutable?有没有其他方法可以解决这个问题。在

编辑: 再次检查了依赖性行者,现在我有了接力,不知道发生了什么。。。 结果如下:

00:00:07.800: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/reg1.2/tclreg12.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) called from "c:\program files (x86)\python27\dlls\TCL85.DLL" at address 0x02468871.
00:00:07.800: Loaded "c:\program files (x86)\python27\tcl\reg1.2\TCLREG12.DLL" at address 0x00440000.  Successfully hooked module.
00:00:07.816: Unloaded "c:\program files (x86)\python27\tcl\reg1.2\TCLREG12.DLL" at address 0x00440000.
00:00:07.816: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/reg1.2/tclreg12.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: The specified module could not be found (126).
00:00:07.832: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/reg1.2/tclreg12.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) called from "c:\program files (x86)\python27\dlls\TCL85.DLL" at address 0x0246889C.
00:00:07.832: Loaded "c:\program files (x86)\python27\tcl\reg1.2\TCLREG12.DLL" at address 0x00440000.  Successfully hooked module.
00:00:07.832: Unloaded "c:\program files (x86)\python27\tcl\reg1.2\TCLREG12.DLL" at address 0x00440000.
00:00:07.832: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/reg1.2/tclreg12.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: The specified module could not be found (126).
00:00:07.925: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/tix8.4.3/Tix843.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) called from "c:\program files (x86)\python27\dlls\TCL85.DLL" at address 0x02468871.
00:00:07.925: Loaded "c:\program files (x86)\python27\tcl\tix8.4.3\TIX843.DLL" at address 0x04480000.  Successfully hooked module.
00:00:07.925: Unloaded "c:\program files (x86)\python27\tcl\tix8.4.3\TIX843.DLL" at address 0x04480000.
00:00:07.925: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/tix8.4.3/Tix843.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: The specified module could not be found (126).
00:00:07.941: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/tix8.4.3/Tix843.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) called from "c:\program files (x86)\python27\dlls\TCL85.DLL" at address 0x0246889C.
00:00:07.956: Loaded "c:\program files (x86)\python27\tcl\tix8.4.3\TIX843.DLL" at address 0x04480000.  Successfully hooked module.
00:00:07.956: Unloaded "c:\program files (x86)\python27\tcl\tix8.4.3\TIX843.DLL" at address 0x04480000.
00:00:07.956: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/tix8.4.3/Tix843.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: The specified module could not be found (126).
00:00:07.956: LoadLibraryA("shell32") called from "c:\program files (x86)\python27\dlls\TK85.DLL" at address 0x024BBACD.
00:00:07.956: LoadLibraryA("shell32") returned 0x75480000.

因此,它有时可以找到DLL,但并不总是这样,然后失败


Tags: addresswithloadfilesprogramtclx86at
2条回答

很可能C程序找不到Tix.dll因为它不在你的道路上。Python可以找到它,因为它与Python可执行文件位于同一目录中,或者在Python知道的子目录中。尝试将dll路径添加到path环境变量中。在

nameofexecutable属性是在Tcl库初始化期间设置的(派生自Tcl_FindExecutable()的参数,我不知道它是如何被调用的,但肯定是:它被用来做各种事情)。你不能把它设置在任何其他点。然而,Tcl实际上并没有在您无法覆盖的情况下使用该值。在

相反,您应该考虑将^{}环境变量设置为要在其中搜索包定义的目录的Tcl列表。或者,您可以将目录添加到Tcl中的auto_path全局变量中(使用lappend auto_path),该变量包含要查找的实际列表(实际上,它也在该变量中列出的位置的直接子目录中查找)。当然,这必须在加载Tix之前完成。在

相关问题 更多 >