0

I'm trying to use py2exe to build an executable on 64-bit Windows 7 with Anaconda (Python 3.4) for a project of mine that depends on a lot of libraries. Some of the more complex ones include vispy (pyopengl), PyQt4, numba, and scipy. I've been stepping through various errors to try to get a working executable, but have hit a road block with no clear way forward. Currently, the py2exe command completes, but I get the following error when running the exe:

...
    from numba import jit
  File "C:\Anaconda3\envs\sift_py2exe\lib\site-packages\numba\__init__.py", line
 13, in <module>
    from .pycc.decorators import export, exportmany
  File "C:\Anaconda3\envs\sift_py2exe\lib\site-packages\numba\pycc\__init__.py",
 line 12, in <module>
    from .cc import CC
  File "C:\Anaconda3\envs\sift_py2exe\lib\site-packages\numba\pycc\cc.py", line
4, in <module>
    from distutils.command import build_ext
  File "C:\Anaconda3\envs\sift_py2exe\lib\distutils\command\build_ext.py", line
17, in <module>
    from site import USER_BASE
ImportError: No module named 'site'

I was able to do a small workaround by adding the C:\Anaconda3\envs\sift_py2exe\Lib directory to sys.path in my main script, but I doubt that's going to help me much later. Not to mention I had more scipy DLL issues after that.

Here are the relevant parts of my setup.py:

try:
    import py2exe
    from llvmlite.binding.ffi import _lib_dir, _lib_name
    kwargs["data_files"] = [('.', [os.path.join(_lib_dir, _lib_name), os.path.join(_lib_dir, "MSVCP120.dll"), os.path.join(_lib_dir, "MSVCR120.dll")])]
    kwargs["console"] = [{
        'script': 'cspov/__main__.py',
        'dest_base': "SIFT",
        }]
    kwargs["options"] = {'py2exe': {"includes": ["vispy.app.backends._pyqt4", "PyQt4.QtNetwork"]}}
except ImportError:
    print("'py2exe' and/or 'llvmlite' not available")

I've tried adding the "Lib" directory in setup.py and then including "site", but it doesn't find the module. Any ideas? Thanks.

Side note: I'm using the Microsoft DLLs from llvmlite as a quick workaround because I couldn't get it to work in any of the normal ways.

djhoese
  • 3,567
  • 1
  • 27
  • 45

1 Answers1

0

This isn't the answer I was hoping for, but I was able to get a working executable when I switched to pyinstaller. All of the other SO questions I saw relevant to my problem had similar "solutions".

djhoese
  • 3,567
  • 1
  • 27
  • 45