Search code examples
pythonpython-3.xcx-freeze

TypeError: 'module' object is not callable using cx_freeze


I've frozen my app with cx_Freeze and when running the .exe I get this error (only error):

C:\Python34\build\exe.win32-3.4>run.exe
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
, in <module>
    exec(code, m.__dict__)
  File "run.py", line 18, in <module>
  File "C:\Python34\Socket.py", line 5, in openSocket
    s = socket.socket()
TypeError: 'module' object is not callable

If I run my app in Python then it works perfectly fine.I have done import socket in both the main python file (run.py) and the one mentioned in the error above (Socket.py)

How do I fix this?


Solution

  • Try renaming your "Socket.py" file to something else ("socket_maker.py"). Then delete all *.pyc files from the current directory (especially anything called socket.pyc).

    I'm thinking that the module name you are trying to import is conflicting with the object and function names.