cx_freeze and pycrypto is missing modules?
Question: Here is my setup.py file for Python 3.3:

    
    
    #/usr/bin/env python3
    import sys
    from cx_Freeze import setup, Executable
    
    # Dependencies are automatically detected, but it might need fine tuning.
    build_exe_options = {
        "packages": [
            "os","io","copy","struct","hashlib","random",
            "urllib","pycurl","json","Crypto"
        ],
        "includes": [        "urllib.parse",    ],
        "excludes": ["tkinter"],
        "icon":"backup.ico"
    }
    
    setup(  name = "BlindBackup",
            version = "1.0",
            description = "BlindBackup client",
            options = {"build_exe": build_exe_options},
            executables = [Executable("backup.py", base=None)])
    

I can execute "py -3 setup.py build_exe" but the exe won't work. By starting
the generated backup.exe I get this error message:

    
    
    ImportError: No module named 'Crypto.Cipher'; Crypto is not a package
    

However, Crypto is a package! I have also tried to add these into the includes
section:

    
    
        "includes": ["urllib.parse",
                     "Crypto","Crypto.Cipher","Crypto.Cipher.AES",],
    

But then I cannot even build the exe:

    
    
     File "C:\Python33\lib\site-packages\cx_Freeze\dist.py", line 362, in setup
       distutils.core.setup(**attrs)
     File "C:\Python33\lib\distutils\core.py", line 148, in setup
       dist.run_commands()
     File "C:\Python33\lib\distutils\dist.py", line 929, in run_commands
       self.run_command(cmd)
     File "C:\Python33\lib\distutils\dist.py", line 948, in run_command
       cmd_obj.run()
     File "C:\Python33\lib\site-packages\cx_Freeze\dist.py", line 232, in run
       freezer.Freeze()
     File "C:\Python33\lib\site-packages\cx_Freeze\freezer.py", line 603, in Freeze
    
       self.finder = self._GetModuleFinder()
     File "C:\Python33\lib\site-packages\cx_Freeze\freezer.py", line 343, in _GetMouleFinder
       finder.IncludeModule(name)
     File "C:\Python33\lib\site-packages\cx_Freeze\finder.py", line 678, in IncludeModule
       namespace = namespace)
     File "C:\Python33\lib\site-packages\cx_Freeze\finder.py", line 386, in _ImportModule
       raise ImportError("No module named %r" % name)
    ImportError: No module named 'Crypto.Cipher'
    

Which makes no sense, because **there is** a module named Crypto.Cipher.

You can test the same setup.py script with python 3 - just create a backup.py
script and put this inside:

    
    
    from Crypto.Cipher import AES
    

It has been suggested that I install precompiled voidspace modules ( see
[Error executing the result of cx_freeze using
pycrypto](http://stackoverflow.com/questions/19066437/error-executing-the-
result-of-cx-freeze-using-pycrypto) ) but it doesn't work either. I did not
want to write comment to a 7 month old question, maybe that is what I should
have done? Anyway, I have this problem now and I cannot fix this on my own.
Please help me!


Answer: Okay, I was silly. I have created a module in my project called "crypto.py".
It is true that this module was a different one under Linux. However, under
Windows, the package "Crypto" and the module "crypto" appeared to be the same.
cx_Freeze confused them, and tried to find Cipher module under the crypto.py
"packacge" which was a module instead.

Refactored my module to a different name and now it works!

