在网络驱动器上安装带有 python win32 扩展的 python

发布于 2024-08-22 20:08:52 字数 559 浏览 10 评论 0原文

我需要保持大量 Windows XP 计算机运行相同版本的 python,并带有各种模块,其中之一是 python-win32。我考虑过在所有客户端机器都安装的网络驱动器上安装python,然后只调整客户端上的路径。 Python 从网络启动正常,但是当导入 win32com 时,我收到一个弹出错误消息:

无法在动态链接库pywintypes24.dll中定位程序入口点?PyWinObject_AsHANDLE@@YAHPAU_object@@PAPAXH@Z

关闭我在控制台中收到的消息对话框后,

导入错误:DLL 加载失败:找不到指定的过程。

我在 python 目录中搜索了 pywintypes24.dll,它位于 "Lib\site-packages\pywin32_system32" 中。

我缺少什么?是否有另一种方法可以安装 Python + Python-Win32 + 附加模块一次并让它们在许多机器上运行?我无法使用 Microsoft 系统管理工具,因此我需要技术含量较低的产品。

I need to keep a large number of Windows XP machines running the same version of python, with an assortment of modules, one of which is python-win32. I thought about installing python on a network drive that is mounted by all the client machines, and just adjust the path on the clients. Python starts up fine from the network, but when importing win32com I get a pop-up error saying:

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

after dismissing the message dialog I get in the console:

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

I searched the python directory for the pywintypes24.dll and it is present in "Lib\site-packages\pywin32_system32" .

What am I missing and is there another way in which I can install Python + Python-Win32 + additional module once and have them running on many machines? I don't have access to the Microsoft systems management tools, so I need to be a bit more low-tech than that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

も让我眼熟你 2024-08-29 20:08:52

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

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

另一件重要的事情是 Good Luck!。原因是您可能需要以 admin 身份执行此操作。就我而言,这种设置适用于除一台计算机之外的所有计算机。我还是不明白为什么。

On every machine you have to basically run following pywin32_postinstall.py -install once. Assuming your python installation on the network is N:\Python26, run following command on every client:

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

Another important thing is Good Luck!. The reason is that you might need to do this as admin. In my case such setup worked for all but one computer. I still did not figure out why.

梦里人 2024-08-29 20:08:52

Python(或者准确地说,操作系统)使用 os.environ["PATH"] 搜索 DLL,而不是通过搜索 sys.path。

因此,您可以使用简单的 .cmd 文件启动 Python,该文件将 \server\share\python26 添加到路径(假设安装程序(或您)从 \server\share\python26\lib\site-packages\pywin32 复制了 DLL) 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 (or precisely, the OS) searches the DLLs using os.environ["PATH"] and not by searching sys.path.

So you could start Python using a simple .cmd file instead which adds \server\share\python26 to the path (given the installer (or you) copied the DLLs from \server\share\python26\lib\site-packages\pywin32-system32 to \server\share\python26).

Or, you can add the following code to your scripts before they try to import win32api etc:

    # 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
够钟 2024-08-29 20:08:52

您可以使用启动时运行的批处理文件

  • 挂载网络share (net use \\server\share)
  • 将 Python 和软件包安装程序从网络共享复制到本地文件夹
  • 根据安装的版本检查 msi 安装程序的版本
  • 如果不同,请卸载 Python 和所有依赖于版本的版本软件包
  • 重新安装所有软件包

这几乎是您自己的该软件的中央管理系统。

You could use batch files running at boot to

  • Mount the network share (net use \\server\share)
  • Copy the Python and packages installers from the network share to a local folder
  • Check version of the msi installer against the installed version
  • If different, uninstall Python and all version dependent packages
  • Reinstall all packages

This would be pretty much a roll your own central management system for that software.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文