No module named 'charset_normalizer.md__mypyc'
Asked Answered
V

8

9

I'm using PyInstaller to compile a program and keep coming across the error "No module named 'charset_normalizer.md__mypyc.'" The Charset-Normalizer package is installed.

As a test, I tried re-compiling a program that I had previously created in early September without issue, but now receive the same error. I thought that maybe there is an issue with the versions of either PyInstaller or Charset-Normalizer so I've experimented with different versions, but cannot get it to work.

Visionary answered 24/10, 2022 at 14:38 Comment(0)
R
17

You are probably missing the "chardet" library I installed it and it worked.

pip install chardet
Rillis answered 31/10, 2022 at 2:52 Comment(2)
Your comment says "Charted" but your code sample says "Chardet" I assume one is correct and the other is not?Psych
Chardet is LGPL, so bundling it with pyinstaller means you should release the source code of your app. charset-normalizer is not LGPL and replaces chardet, so there's a good reason not to install chardet.Stoned
H
7

I had the EXACT problem. Scripts that I was able to make into executables using Pyinstaller before I could no longer do so again. In my script I used the pdfplumber package, which when you install it also installs other packages like pillow, wand, charset-normalizer, etc.

Since the error was regarding charset-normalizer for me as well, I tried different versions of it. For me it was version 2.1.0 that made the executable work again. Install it with the "pip install charset-normalizer==2.1.0" command: https://pypi.org/project/charset-normalizer/2.1.0/.

If it does not work, go to "Release history" on that link and try another version. Try to remember when was the last time you created a working executable and get the version you think will work for you.

Haemophilic answered 1/11, 2022 at 18:4 Comment(0)
S
5

This worked for me:

I just added

from charset_normalizer import md__mypyc

to the top of my python script.

https://mcmap.net/q/1169936/-how-to-fix-a-pyinstaller-39-no-module-named-39-error-when-my-script-imports-the-modules-pikepdf-and-pdfminer3

If you don't have the charset-normalizer library installed, then you should install it using the following command:

pip install charset-normalizer
Stercoricolous answered 22/11, 2022 at 23:41 Comment(1)
I used this import statement to fix my build with nuitka as wellOntology
L
3

Pyinstaller may sometimes miss your dependency. In such a case run pyinstaller with the --collect-all option. In this case --collect-all charset_normalizer should force pyinstaller to include the dependency.

Lamberto answered 13/1, 2023 at 2:46 Comment(0)
S
2

This error is expected because of the way pyinstaller works.

To fix it, pass the pyinstaller CLI flag: --hidden-import charset_normalizer.md__mypyc

Or, if using SPEC file, set the hiddenimports param passed to Analysis:

     a = Analysis(['minimal.py'],
         pathex=['/Developer/PItests/minimal'],
         binaries=None,
         datas=None,
         hiddenimports=["charset_normalizer.md__mypyc"],
         hookspath=None,
         runtime_hooks=None,
         excludes=None,
         cipher=block_cipher)

See https://github.com/Ousret/charset_normalizer/blob/master/docs/community/faq.rst#i-cant-build-standalone-executable for more context.

Stoned answered 18/5, 2023 at 23:42 Comment(0)
H
1

I have already installed chardet and charset-normalizer, but I still had the problem. Then I saw this Github issue. As suggested by IsraelAbebe, I solved the problem by

python -m pip install charset-normalizer==2.1.0
Hinkley answered 17/4, 2023 at 15:35 Comment(0)
V
0

I got it to work by installing older versions of PyInstaller and Charest-Normalizer. Anytime this messages pops-up, consider installing an older version of the package.

Visionary answered 1/11, 2022 at 10:52 Comment(0)
E
0

In my case I had to change path environment to the previous python SDK where poetry was installed, it was changed for some reason to other sdk.

Exegesis answered 11/7, 2024 at 12:7 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.