PyWin32和Python 3.8.0

问题描述 投票:0回答:2

Python 3.8.0最近已发布(在[[20191014上,可以从[Python]: Python 3.8.0下载)。 PyWin32已在[PyPI]: pywin32 225上构建(已发布在[[20190915)。不幸的是,在pip install之后,它不起作用。

示例:

[cfati@CFATI-5510-0:e:\Work\Dev\StackOverflow\q058631512]> sopr.bat *** Set shorter prompt to better fit when pasted in StackOverflow (or other) pages *** [prompt]> "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\Scripts\python.exe" Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32api >>> ^Z [prompt]> "e:\Work\Dev\VEnvs\py_064_03.08.00_test0\Scripts\python.exe" Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32api Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: DLL load failed while importing win32api: The specified module could not be found. >>> ^Z

[Notes:

对于

    Python 3.7

,我也将
  • PyWin32
  • 模块升级到了最新版本,并且可以使用较旧的[[PyWin32版本适用于较旧的Python版本(
  • 2.7,3.53.6
  • 可在64bit32bit上重现
    python windows dll pywin32 python-3.8
    2个回答
    1
    投票
    URL引用了2个以上:

    [Python 3.8.Docs]: What’s New In Python 3.8 - Changes in the Python API其中陈述(重点是我的):

    • Windows上扩展模块的DLL依赖关系和加载了ctypes的DLL现在可以更安全地解决。仅搜索系统路径,包含DLL或PYD文件的目录以及添加有add_dll_directory()的目录以查找加载时间相关性。
      特别是,不再使用PATH和当前工作目录,对它们的修改将不再对正常的DLL解析产生任何影响。
  • 同时,我自己进行了一些挖掘,发现(对于win32api.pyd
  • )是

  • pywintypes38.dll(这是

    。pyd的依赖项)找不到的(我也在对此问题的评论中指定了此内容。)>解决方案

    (实际上是变通办法(或多或少),直到正式和向后兼容的修复程序发布为止:]]

    Force

      pywintypes38.dll
    通过导入加载(因为它也是一个[[Python

    模块,在这种情况下,它不属于上述规则))
  • 之前
  • 任何

    PyWin32 模块:import pywintypes import win32api 如果使用COM

    ,则需要import pythoncom

    pywin32_system32

    添加到。dll
    搜索路径(从上面跟随新模型)。有多种方法:
  • v-python在问题[[URL

    中的注释,其中提供了一个小片段(我没有对其进行测试)]文件中的所有操作(在解释器启动时执行,因此无需更改现有代码)。不幸的是,
  • AppVeyor
  • 自动化测试存在一个问题,该问题失败了(但由于其他一些原因),因此它停留了一段时间。无论如何,在本地
  • [[[1
  • (在我的两个[[Python

    VEnv上)都应用更改,解决了这个问题(在一个上,而没有破坏另一个):[cfati@CFATI-5510-0:e:\Work\Dev\StackOverflow\q058631512]> sopr.bat *** Set shorter prompt to better fit when pasted in StackOverflow (or other) pages *** [prompt]> "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\Scripts\python.exe" -c "import win32api" [prompt]> "e:\Work\Dev\VEnvs\py_064_03.08.00_test0\Scripts\python.exe" -c "import win32api" [prompt]>

    注意#1。] >>检查[SO]: Run/Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? (@CristiFati's answer)
    修补程序
    utrunner
    部分)以了解如何应用修补程序(在[[Win上)。

    已成功在python 3.8上使用pycharm安装pywin32 v225。

    导入

    pywintypes

    © www.soinside.com 2019 - 2024. All rights reserved.