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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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.

You Might Also Like