py2exe - No system module 'pywintypes'

前端 未结 4 1874
长情又很酷
长情又很酷 2021-02-20 05:33

I\'m trying to convert a simple Python script into a Windows executable. My setup.py script is:

from distutils.core import setup
import py2exe

setup(
    name =         


        
4条回答
  •  眼角桃花
    2021-02-20 06:33

    I had a different problem with py2exe failing to find pywintypes27.dll - it was failing to find the file inside build_exe.isSystemDLL. The solution is to add the location of the DLLs in the path (at least the hack is to do so):

    import site
    for site_path in site.getsitepackages():
        pywin32_path = os.path.join(site_path, "pywin32_system32")
        if os.path.isdir(pywin32_path):
            os.environ["PATH"] = os.environ["PATH"] + ";" + pywin32_path
    

提交回复
热议问题