py2exe missing distutils modules in virtualenv



我正在尝试构建我的项目(Python 2.7.5(的可执行文件,但在尝试运行可执行文件时出现以下错误。
ERROR ProjectPythonlibrary.zipdistutils__init__.py:14: UserWarning: The virtualenv distutils package at %s appears to be in the same location as the system distutils? Traceback (most recent call last): File "main.py", line 130, in <module> ... File "pandascompat__init__.pyo", line 32,in <module> File "zipextimporter.pyo", line 82, in load_module File "distutils__init__.pyo", line 25, in <module> ERROR ImportError: cannot import name dist

在搜索了这个问题的解决方案后,我知道这一定是因为 virtualenv 中的 distutils 与 Python 安装 Lib 目录中的内容不同。因此,我一直在尝试在 virtualenv 中排除/删除 distutils,并在可执行构建期间添加我的源解释器的 distutils 包。
cxfreeze存在确切的解决方案,但找不到py2exe的替代解决方案。我的 setup.py 选项看起来像

distutils.core.setup(
options = {"py2exe": {
"compressed": 1,
"optimize": 1,
"bundle_files": 1,
"packages": ['psycopg2', 'lxml', 'sqlalchemy', 'openpyxl', 'pandas', 'numpy']
}}

非常感谢对此的任何帮助。谢谢!

鉴于您共享的信息,您似乎在排除distutils方面走错了方向。错误(警告(指出distutils package at %s appears to be in the same location as the system distutils

尝试使用所需的库创建一个全新的虚拟环境,然后重新构建。

最新更新