在网络dri上安装带有python win32扩展的python

2024-09-24 00:36:08 发布

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

我需要让大量的Windows XP机器运行同一版本的python,其中有一个模块是python-win32。我想把python安装到一个由所有客户机安装的网络驱动器上,然后调整客户机上的路径。Python从网络上启动很好,但是当导入win32com时,出现一个弹出的错误,说:

The procedure entry point ?PyWinObject_AsHANDLE@@YAHPAU_object@@PAPAXH@Z could not be located in the dynamic link library pywintypes24.dll

在取消消息对话框后,我在控制台中获得:

ImportError: DLL load failed: The specified procedure could not be found.

我在python目录中搜索pywintypes24.dll,它出现在“Lib\site packages\pywin32_system32”中。

我遗漏了什么,还有没有其他方法可以让我一次性安装Python+Python-Win32+附加模块并让它们在许多机器上运行?我无法使用微软的系统管理工具,所以我需要比这低一点的技术。


Tags: 模块the版本网络客户机windowsnotbe
3条回答

Python(或者确切地说,OS)使用OS.environ[“PATH”]而不是通过搜索sys.PATH来搜索dll。

因此,您可以使用一个简单的.cmd文件启动Python,该文件将\server\share\python26添加到路径(给定安装程序(或您)将dll从\server\share\python26\lib\site packages\pywin32-system32复制到了\server\share\python26)。

或者,您可以在脚本尝试导入win32api等之前将以下代码添加到脚本中:

    # Add Python installation directory to the path, 
    # because on Windows 7 the pywin32 installer fails to copy
    # the required DLLs to the %WINDIR%\System32 directory and
    # copies them to the Python installation directory instead.
    # Fortunately, in Python it is possible to modify the PATH
    # before loading the DLLs.
    os.environ["PATH"] = sys.prefix + ";" + os.environ.get("PATH")
    import win32gui
    import win32con

“我在python目录中搜索了pywintypes24.dll,它出现在”Lib\site packages\pywin32_system32“”中。dll的存在没有问题。是那个dll中的入口点吗?

您是否尝试在非网络驱动器上安装完全相同的配置?

您是否尝试导入包中的其他模块?

你有没有用依赖沃克或类似的工具检查过dll?

pywintypes24.dll中的“24”是否意味着Python 2.4?你在运行什么版本的Python?

在每台机器上,您基本上都必须在pywin32_postinstall.py -install之后运行一次。假设网络上的python安装是N:\Python26,请在每个客户端上运行以下命令:

N:\Python26\python.exe N:\Python26\Scripts\pywin32_postinstall.py -install

另一件重要的事情是Good Luck!。原因是你可能需要以admin的方式来做。在我的情况下,这样的设置只适用于一台计算机。我还是不明白为什么。

相关问题 更多 >