Search code examples
python-3.xexecutablespydercx-freeze

using cx_freeze in spyder


I installed cx_Freeze using pip:

C:\Users\Sarah\Documents\PythonScripts>python -m pip install cx_Freeze --upgrade
Collecting cx_Freeze
  Downloading cx_Freeze-5.0.2-cp36-cp36m-win_amd64.whl (162kB)
Installing collected packages: cx-Freeze
Successfully installed cx-Freeze-5.0.2

However, I get this error when I try to execute a script:

setup.py build
Traceback (most recent call last):
  File "C:\Users\Sarah\Documents\PythonScripts\setup.py", line 9, in <module>
    from cx_freeze import setup, Executable
ImportError: No module named cx_freeze

When I check the system path, I get all this information

print (sys.path)
['', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\spyder\\utils\\site', 'C:\\Users\\Sarah\\Documents\\PythonScripts', 'C:\\Users\\Sarah\\Anaconda3\\python36.zip', 'C:\\Users\\Sarah\\Anaconda3\\DLLs', 'C:\\Users\\Sarah\\Anaconda3\\lib', 'C:\\Users\\Sarah\\Anaconda3', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\Sphinx-1.5.6-py3.6.egg', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\win32', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\win32\\lib', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\Pythonwin', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\setuptools-27.2.0-py3.6.egg', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\Sarah\\.ipython']

I am assuming that somehow, the path to the cx_freeze module is lost in here somewhere. I would really appreciate some simple (novice user) ideas for how to go about fixing this.

I tried copying the folder cx-freeze to the PythonScripts folder but that didn't help.


Solution

  • I know why you are getting this error and I do not think it has anything to do with the file path.

    Try:

    from cx_Freeze import setup, Executable
    

    in the place of

    from cx_freeze import setup, Executable
    

    in your setup.py script

    and this error should fix (you had f not F).