I'm trying to use cx_freeze to create a Windows executable from a Python script that imports pyrax (to interface with Rackspace). Pyrax requires oslo (https://github.com/openstack/oslo.utils), a module for working with OpenStack that I have installed. When I try to run the compiled .exe, it says that it can't find the module 'oslo.utils'. When I try to include that module, or just the oslo module, in my setup.py file, I get the following error:
running build
running build_exe
Traceback (most recent call last):
File "setup.py", line 45, in <module>
executables = [execu]
File "C:\Users\Devin\Anaconda\lib\site-packages\cx_Freeze\dist.py", line 362, in setup
distutils.core.setup(**attrs)
File "C:\Users\Devin\Anaconda\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Users\Devin\Anaconda\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Users\Devin\Anaconda\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Users\Devin\Anaconda\lib\distutils\command\build.py", line 127, in run
self.run_command(cmd_name)
File "C:\Users\Devin\Anaconda\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:\Users\Devin\Anaconda\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Users\Devin\Anaconda\lib\site-packages\cx_Freeze\dist.py", line 232, in run
freezer.Freeze()
File "C:\Users\Devin\Anaconda\lib\site-packages\cx_Freeze\freezer.py", line 606, in Freeze
self.finder = self._GetModuleFinder()
File "C:\Users\Devin\Anaconda\lib\site-packages\cx_Freeze\freezer.py", line 346, in _GetModuleFinder
finder.IncludeModule(name)
File "C:\Users\Devin\Anaconda\lib\site-packages\cx_Freeze\finder.py", line 678, in IncludeModule
namespace = namespace)
File "C:\Users\Devin\Anaconda\lib\site-packages\cx_Freeze\finder.py", line 386, in _ImportModule
raise ImportError("No module named %r" % name)
ImportError: No module named 'oslo.utils'
I'm on Windows 8 running Python 2.7 via a Continuum Anaconda install. I've installed oslo v1.0.0 using pip (and reinstalled it in an attempt to fix this, but to no avail). Cx_freeze is version 4.3.3, and the oslo module not an egg or zip, but is foldered with everything else under site-packages.
'Import oslo' and 'import oslo.utils' both work in the interpreter. Other modules manually included in setup.py work correctly. My setup.py file looks like this:
import sys
from cx_Freeze import setup, Executable
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
# include email.__init__ lazy imports manually for pyrax
MIMENAMES = [
'audio',
'base',
'image',
'message',
'multipart',
'nonmultipart',
'text',
]
email_includes = ['email.mime.' + x for x in MIMENAMES]
includes = ['oslo.utils']
includes.extend(email_includes)
include_files = []
execu = Executable(
script = "main.py",
initScript = None,
base = base,
targetName = "main.exe",
compress = False,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)
setup( name = "issgmain",
version = "0.1",
description = "my description",
options = {"build_exe": {"includes":includes, "include_files": include_files}},
executables = [execu]
)
Thoughts and workarounds much appreciated. Thanks!
'oslo.py'
to theincludes
list. The line numbers also indicate that there's more in your setup.py script than you've shown. Includes is a list of module names, not filenames, so you should include 'oslo', without the .py extension.import oslo.utils; print(oslo.utils)
to see where it's loaded from in Python?print(sys.path)
into your setup.py file, isC:\Users\Devin\Anaconda\lib\site-packages
one of the directories it shows in the list?"packages":["oslo"]
to the build_exe options, does it make any difference? Can you show the full output from freezing (put it in a pastebin)?"namespace_packages":["oslo"]