简体   繁体   中英

py2exe missing distutils modules in virtualenv

I am trying to build executable file of my project(Python 2.7.5) but getting this below error when trying to run the executable.
ERROR \\ProjectPython\\library.zip\\distutils\\__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 "pandas\\compat\\__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

After searching for solutions to this issue, I got to know that this must be because of distutils in virtualenv is different from whats in Python installation Lib directory. So, I have been trying to exclude/remove distutils in virtualenv and add distutils package of my origin interpreter during executable build.
That exact solution exists for cxfreeze, but couldn't find alternate solution for py2exe. My setup.py options looks something like

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

Any help on this is much appreciated. Thanks !

Given the information you've shared, it seems that you might be going the wrong direction with excluding distutils. The error (warning) is stating that distutils package at %s appears to be in the same location as the system distutils .

Try creating a fresh virtual environment with the needed libraries and building again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM