Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'COMMON_SAFE_ASCII_CHARACTERS' from 'charset_normalizer.constant'

Traceback (most recent call last):
  File "g:\mydrive\ \pdftotext_pdfminer.py", line 3, in <module>
    from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
  File "C:\Users\ \anaconda3\envs\ \lib\site-packages\pdfminer\pdfinterp.py", line 7, in <module> 
    from .cmapdb import CMap
  File "C:\Users\ \anaconda3\envs\ \lib\site-packages\pdfminer\encodingdb.py", line 7, in <module>
    from .psparser import PSLiteral
  File "C:\Users\ \anaconda3\envs\ \lib\site-packages\pdfminer\psparser.py", line 22, in <module>
    from .utils import choplist
  File "C:\Users\ \anaconda3\envs\ \lib\site-packages\pdfminer\utils.py", line 31, in <module>
    import charset_normalizer  # For str encoding detection
  File "C:\Users\ \anaconda3\envs\ \lib\site-packages\charset_normalizer\__init__.py", line 23, in <module>
    from charset_normalizer.api import from_fp, from_path, from_bytes, normalize
  File "C:\Users\ \anaconda3\envs\ \lib\site-packages\charset_normalizer\api.py", line 10, in <module>
    from charset_normalizer.md import mess_ratio
  File "charset_normalizer\md.py", line 5, in <module>
ImportError: cannot import name 'COMMON_SAFE_ASCII_CHARACTERS' from 'charset_normalizer.constant' (C:\Users\ \anaconda3\envs\ \lib\site-packages\charset_normalizer\constant.py)

This error happens whenever I'm using pdfminer. I also installed pdfminer-six

My code worked just fine until two days ago. It started to happen today when I tried to just run it again without any adjustment in the file

I'm assuming maybe it's the pdfminer's problem but there's no update about the module...

(I'm running this on my conda env)

Does anyone know what this error means? and how to fix it?

like image 646
Lena.J Avatar asked Sep 08 '25 12:09

Lena.J


1 Answers

When I encountered this I used:

pip install chardet
like image 168
Ricky Shao Avatar answered Sep 11 '25 01:09

Ricky Shao