jsvine / pdfplumber

Plumb a PDF for detailed information about each char, rectangle, line, et cetera — and easily extract text and tables.
MIT License
6.57k stars 659 forks source link

ModuleNotFoundError: No module named 'pdfplumber' #597

Closed sollama closed 2 years ago

sollama commented 2 years ago

Describe the bug

I'm working in jupyter notebook. I'm unable to import pdfplumber for some reason

Code to reproduce the problem

!pip install pdfplumber --user import pdfplumber

PDF file

Please attach any PDFs necessary to reproduce the problem.

If you need to redact text in a sensitive PDF, you can run it through JoshData/pdf-redactor.

Expected behavior

For the import cell to run through

Actual behavior

What actually happened, instead? Screenshot shows that pdfplumber was installed successfully, but I received a ModuleNotFoundError: No module named 'pdfplumber'.

Screenshots

If applicable, add screenshots to help explain your problem. image

Environment

Additional context

Add any other context/notes about the problem here.

jsvine commented 2 years ago

Hi @sollama, and thanks for your interest in this library. Usually when I see errors like that, it's unrelated to pdfplumber but rather more generally related to the Python environment. One way to test this: What happens if you try doing the same thing, but instead of pdfplumber you try installing and importing any other external Python library, e.g., requests?

jsvine commented 2 years ago

Looking more closely at the error messages, it appears that you may be using pip in an Anaconda environment. What if you try replacing !pip install pdfplumber with !conda install pdfplumber?

sollama commented 2 years ago

Hi,

Thanks for getting back so quickly.

  1. Installing and importing requests has no error
  2. I tried using !conda install pdfplumber. I received this error: image

Like they suggested, I went on the anaconda site to find the package and tried this next. I still got an error, error message pasted below.

image

On Thu, Feb 3, 2022 at 2:29 PM Jeremy Singer-Vine @.***> wrote:

Looking more closely at the error messages, it appears that you may be using pip in an Anaconda environment. What if you try replacing !pip install pdfplumber with !conda install pdfplumber?

— Reply to this email directly, view it on GitHub https://github.com/jsvine/pdfplumber/issues/597#issuecomment-1029461110, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJYQBEULJOO7EDXYCMCJ5WDUZL6TFANCNFSM5NPVOD5Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

jsvine commented 2 years ago

Thanks for sharing that. And, hmmm, I'm not very familiar with Anaconda/conda debugging, so I'm not quite sure what's going on there. As an alternative, perhaps create a new, pure-pip environment, and retry there? Something like:

cd path/to/my/project
python -m venv venv  # create the virtual environment
source venv/bin/activate # activate it
pip install jupyter pdfplumber # install the libraries
jupyter notebook # launch a Jupyter notebook from within the environment
samkit-jain commented 2 years ago

@sollama Have you tried installing pdfplumber without --user? Using --user is not required when you are running inside a virtual environment. I tested this on Google Colaborator and if I install via --user, I can't import the package but if I install without it, I am able to use just fine.

sollama commented 2 years ago

It worked when I installed without the - - user. Thank you all for your help :)

On Fri, Feb 4, 2022 at 2:03 AM Samkit Jain @.***> wrote:

@sollama https://github.com/sollama Have you tried installing pdfplumber without --user? Using --user is not required when you are running inside a virtual environment. I tested this on Google Colaborator https://colab.research.google.com/ and if I install via --user, I can't import the package but if I install without it, I am able to use just fine.

— Reply to this email directly, view it on GitHub https://github.com/jsvine/pdfplumber/issues/597#issuecomment-1029823302, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJYQBERCJDQZ6KU5F75MQ4LUZOP5LANCNFSM5NPVOD5Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>