marcelotduarte / cx_Freeze

cx_Freeze creates standalone executables from Python scripts, with the same performance, is cross-platform and should work on any platform that Python itself works on.
https://marcelotduarte.github.io/cx_Freeze/
Other
1.36k stars 220 forks source link

ModuleNotFoundError: No module named 'encodings' on OSX Anaconda python=3.7 #1152

Closed AhmetCanSolak closed 3 years ago

AhmetCanSolak commented 3 years ago

Hello all,

I am getting

Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

and saw back in previous versions some others got same/similar errors when they wanted to run the applications they built.

setup.py I used:

import sys
from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
    base = "Win32GUI"

options = {"build_exe": {"includes": "atexit"}}

executables = [Executable("gui.py", base=base)]

setup(
    name="simple_PyQt5",
    version="0.1",
    description="Sample cx_Freeze PyQt5 script",
    options=options,
    executables=executables,
)

To Reproduce Steps to reproduce the behavior I run python setup.py build it goes smooth. This is a detailed PyQt5 application. When I wanted to run what I built, I am getting the aforementioned error.

Desktop (please complete the following information):

marcelotduarte commented 3 years ago

For anaconda a new 6.7 version using more recent macos sdk was updated today. Check if have this new package (https://anaconda.org/conda-forge/cx_freeze)

For macos we have another method to build, try to use it: python setup.py bdist_mac

See more information on issue #1033

Please confirm if you get success.

AhmetCanSolak commented 3 years ago

Thanks for prompt response @marcelotduarte !

I tried with latest version 6.7 on conda-forge, unfortunately still getting the same module not found error with encodings. Also tried with bdist_mac command but still got the same error. I wanted to try with pypi installation but getting an 'Unknown attribute kind (61) error during building and not able to install.

marcelotduarte commented 3 years ago

Can you put a complete traceback. Before install from pypi in conda, I suggest to you install importlib-metadata from conda-forge.

marcelotduarte commented 3 years ago

cx_Freeze 6.8b1 has just been released with fixes for pyqt5. Please, try it out and report. pip install cx-Freeze==6.8b1

marcelotduarte commented 3 years ago

I wanted to try with pypi installation but getting an 'Unknown attribute kind (61) error during building and not able to install.

I confirmed that with cx_Freeze 6.7 has issues in conda. Installing from pypi on conda has some caveats, so I updated the documentation: https://cx-freeze.readthedocs.io/en/latest/installation.html#anaconda-miniconda

And released cx_Freeze 6.8b3. Please, try it out and report.

I tested the sample: https://github.com/marcelotduarte/cx_Freeze/tree/6.8b3/cx_Freeze/samples/pyqt5 pyqt5-test_pyqt5-macosx-10 9-x86_64-3 7

marcelotduarte commented 3 years ago

cx_Freeze 6.8 has just been released. pip install --upgrade cx_Freeze Assuming this has been resolved. If you had issues please open a new issue.