Import Error: Cannot Import Name 'Open_Filename' from 'Pdfminer. Utils'

On importing pdfminer.high_level, I am getting an error cannot import name open_filename from pdfminer.utils.

I tried following steps:

  1. pip3 install pdfminer.six
  2. import pdfminer
  3. import pdfminer.high_level

(and encountered error on this line)


ImportError                               Traceback (most recent call last)
<ipython-input-6-772e4980255d> in <module>
----> 1 import pdfminer.high_level

~\anaconda3\lib\site-packages\pdfminer\high_level.py in <module>
     12 from .pdfinterp import PDFResourceManager, PDFPageInterpreter
     13 from .pdfpage import PDFPage
---> 14 from .utils import open_filename
     15 
     16 

ImportError: cannot import name 'open_filename' from 'pdfminer.utils'
1

3 Answers

Hi I had the same issue.

I had installed both pdfminer and pdfminer.six. Please keep pdfminer.six and uninstall pdfminer with:

pip uninstall pdfminer

I faced a similar problem: cannot import name 'open_filename' from 'pdfminer.utils' when using the langchain cookbook. Problem was python v.3.11x. I downgraded my env to 3.8.18 and it worked.

1

I had an older version of pdfminer.six. This is the commit that introduced the open_filename method. Make sure your pdfminer.six version is greater than '20200402'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest