Python Forum
pdfminer package: module isn't found
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pdfminer package: module isn't found
#11
(Sep-13-2022, 07:30 PM)deanhystad Wrote: How are you running this code? What Python are you using? Which OS? How do you run Python?
Using Python IDLE. Python 3.6.9. Ubuntu 18.04. Using Python IDLE.
Reply
#12
(Sep-13-2022, 07:57 PM)snippsat Wrote: Look if have named a file pdfminer.py or folder,is a common mistake in these cases.
Do this.
.....

Output:
>>> import pdfminer >>> dir(pdfminer) ['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__'] >>> import pdfminer.pdfinterp Traceback (most recent call last): File "<pyshell#13>", line 1, in <module> import pdfminer.pdfinterp ModuleNotFoundError: No module named 'pdfminer.pdfinterp' >>>
Reply
#13
When you type "pip list" what shows up for pdfminer?

I'm not sure how, but I do not believe you are importing pdfminer. What you are importing looks completely different.

Type this to see where pdfminer is installed:
Quote:pip show pdfminer
Type this to see the search path for modules. You may need to use python3 instead of python.
Quote:python -c 'import sys; print(sys.path)'
This shows the search path used by Python to find modules.

Locate the pdfminer folder in sys.path. Look at each folder that precedes the folder to see if it contains a file named "pdfminer.py".
Reply
#14
(Sep-14-2022, 12:03 PM)deanhystad Wrote: When you type "pip list" what shows up for pdfminer?

I'm not sure how, but I do not believe you are importing pdfminer. What you are importing looks completely different.

Type this to see where pdfminer is installed:
Quote:pip show pdfminer
Type this to see the search path for modules. You may need to use python3 instead of python.
Quote:python -c 'import sys; print(sys.path)'
This shows the search path used by Python to find modules.

Locate the pdfminer folder in sys.path. Look at each folder that precedes the folder to see if it contains a file named "pdfminer.py".

Output:
pavel@ALABAMA:~$ pip show pdfminer Name: pdfminer Version: 20191125 Summary: PDF parser and analyzer Home-page: http://github.com/euske/pdfminer Author: Yusuke Shinyama Author-email: [email protected] License: MIT Location: /home/pavel/.local/lib/python3.6/site-packages Requires: pycryptodome Required-by: pavel@ALABAMA:~$
Output:
pavel@ALABAMA:~$ python -c 'import sys; print(sys.path)' ['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/pavel/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0'] pavel@ALABAMA:~$
Output:
pavel@ALABAMA:~$ python3 -c 'import sys; print(sys.path)' ['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/pavel/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/local/lib/python3.6/dist-packages/Keras-2.3.0-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/scipy-1.3.1-py3.6-linux-x86_64.egg', '/usr/local/lib/python3.6/dist-packages/LiveWires-2.1-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/pygame-2.0.0.dev4-py3.6-linux-x86_64.egg', '/usr/lib/python3/dist-packages'] pavel@ALABAMA:~$
Reply
#15
There is something wrong with package uninstall.
pip uninstall pdfminer
Also now should use pdfminer.six as PDFMiner is not actively maintained.
Quote:Warning: As of 2020, PDFMiner is not actively maintained.
The code still works, but this project is largely dormant. For the active project, check out its fork pdfminer.six.
pip install pdfminer.six
Also you will get in trouble when use Python 3.6,as many package has drooped support for Python 3.6,so you most upgrade.
Example NumPy that is base for lot of packages has no a required Python 3.8 -->.
Reply
#16
(Sep-14-2022, 01:46 PM)snippsat Wrote: There is something wrong with package uninstall.
pip uninstall pdfminer
Also now should use pdfminer.six as PDFMiner is not actively maintained.
Quote:Warning: As of 2020, PDFMiner is not actively maintained.
The code still works, but this project is largely dormant. For the active project, check out its fork pdfminer.six.
pip install pdfminer.six
Also you will get in trouble when use Python 3.6,as many package has drooped support for Python 3.6,so you most upgrade.
Example NumPy that is base for lot of packages has no a required Python 3.8 -->.
There is 3.10 version that is installed.
From memory I installed it a few months ago, but never used it (probably because of the problems encountered).
I'm just switched to it and tried to install pdfminer.six.
Here's what happened ...
Output:
pavel@ALABAMA:~$ pip install pdfminer.six Traceback (most recent call last): File "/home/pavel/.local/bin/pip", line 5, in <module> from pip._internal.cli.main import main File "/usr/lib/python3/dist-packages/pip/__init__.py", line 22, in <module> from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 73, in <module> vendored("pkg_resources") File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored __import__(modulename, globals(), locals(), level=0) File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 77, in <module> File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module> File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 672, in _load_unlocked File "<frozen importlib._bootstrap>", line 632, in _load_backward_compatible File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/extern/__init__.py", line 43, in load_module File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/_vendor/pyparsing.py", line 943, in <module> collections.MutableMapping.register(ParseResults) AttributeError: module 'collections' has no attribute 'MutableMapping' pavel@ALABAMA:~$
Reply
#17
(Sep-14-2022, 02:06 PM)Pavel_47 Wrote: There is 3.10 version that is installed.
From memory I installed it a few months ago, but never used it (probably because of the problems encountered).
I'm just switched to it and tried to install pdfminer.six.
Here's what happened ...
Some thing is messed up with your system,you also have two Python 3.6 version.
Just to copy from your Path.
# This is the original Python 3.6 that comes with OS
/usr/local/lib/python3.6/dist-packages

# This is an other Python 3.6 that has to be installed at one point because it use <site-packages>
/home/pavel/.local/lib/python3.6/site-packages
There is no Python 3.10 to be seen.
It's relative easy to fix his,but if you struggle basic understating of OS and Python install and have messed it up then it can hard for you to fix it
If you think of installed a new Distro✨ then now is point to do that.

Can of course try virtual environment,but if Python is messed up the that may not work either.
Here a quick demo.
# Check the basic,i use pyenv
tom@tom-VirtualBox:~$ python -V
Python 3.10.5
tom@tom-VirtualBox:~$ which python
/home/tom/.pyenv/shims/python
tom@tom-VirtualBox:~$ pip -V
pip 22.2.2 from /home/tom/.pyenv/versions/3.10.5/lib/python3.10/site-packages/pip (python 3.10)

# Make
tom@tom-VirtualBox:~$ python -m venv pdf_env
tom@tom-VirtualBox:~$ cd pdf_env
tom@tom-VirtualBox:~/pdf_env$ source bin/activate
# Install
pdf_env) tom@tom-VirtualBox:~/pdf_env$ pip install pdfminer.six
Collecting pdfminer.six
  Using cached pdfminer.six-20220524-py3-none-any.whl (5.6 MB)
Collecting charset-normalizer>=2.0.0
  Using cached charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Collecting cryptography>=36.0.0
  Using cached cryptography-38.0.1-cp36-abi3-manylinux_2_24_x86_64.whl (4.0 MB)
Collecting cffi>=1.12
  Downloading cffi-1.15.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (441 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 441.8/441.8 KB 2.6 MB/s eta 0:00:00
Collecting pycparser
  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 KB 3.2 MB/s eta 0:00:00
Installing collected packages: pycparser, charset-normalizer, cffi, cryptography, pdfminer.six
Successfully installed cffi-1.15.1 charset-normalizer-2.1.1 cryptography-38.0.1 pdfminer.six-20220524 pycparser-2.21

# Test that it works
(pdf_env) tom@tom-VirtualBox:~/pdf_env$ python 
Python 3.10.5 (main, Jun 23 2022, 10:51:05) [GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>  from pdfminer.pdfinterp import PDFResourceManager
>>> 
>>> exit() 
Reply
#18
Well ... I tried to repair python staff.
I removed python, but it also removed GUI.
I reinstall GUI and see that version 3.6.9 is still installed (the version that I had before purging).
It's seems impossible to completely remove python staff without corrupting Ubuntu.
So the only solution is to upgrade python to 3.10 leaving 3.6.9 ?

Update post ...
Moreover I've just discovered that despite my actions on removing nothing changed: the python staff remains as it was before purging:

Output:
xxx@ALABAMA:~$ sudo update-alternatives --config python3 [sudo] password for xxx: There are 2 choices for the alternative python3 (providing /usr/bin/python3). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/python3.10 2 auto mode 1 /usr/bin/python3.10 2 manual mode * 2 /usr/bin/python3.6 1 manual mode Press <enter> to keep the current choice[*], or type selection number:
Any idea how to repair this sticky python staff ?
Thanks.
Reply
#19
You select 0
(Sep-15-2022, 09:31 AM)Pavel_47 Wrote: Moreover I've just discovered that despite my actions on removing nothing changed: the python staff remains as it was before purging
Don't remove the default Python 3.6 that comes with OS.
You type 0 to select Python 3.10.
Then you test with python -V to see if it return Python 3.10 as version, eg in link.
Reply
#20
Ok

Output:
xxx@ALABAMA:~$ python3 -V Python 3.10.7
But it seems that there no pip:

Output:
xxx@ALABAMA:~$ pip uninstal pdfminer Traceback (most recent call last): File "/home/pavel/.local/bin/pip", line 5, in <module> from pip._internal.cli.main import main ModuleNotFoundError: No module named 'pip' xxx@ALABAMA:~$
I tried to install it, but faced to dependencies issue:

Output:
xxx@ALABAMA:~$ curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 Defaulting to user installation because normal site-packages is not writeable Collecting pip Downloading pip-22.2.2-py3-none-any.whl (2.0 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 7.0 MB/s eta 0:00:00 Collecting setuptools Downloading setuptools-65.3.0-py3-none-any.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 10.6 MB/s eta 0:00:00 Collecting wheel Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB) Installing collected packages: wheel, setuptools, pip ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. launchpadlib 1.10.13 requires testresources, which is not installed. Successfully installed pip-22.2.2 setuptools-65.3.0 wheel-0.37.1 xxx@ALABAMA:~$
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyside6 module not found ForeverNoob 4 1,275 Aug-18-2023, 04:36 PM
Last Post: snippsat
  Module Not Found Error bitoded 4 1,346 Jan-01-2023, 09:08 AM
Last Post: bitoded
  Module not found question sighhhh12 0 1,448 Sep-09-2022, 05:43 AM
Last Post: sighhhh12
  [SOLVED] Tkinter module not found Milan 7 21,561 Aug-05-2022, 09:45 PM
Last Post: woooee
  No module found when I run a main.py tomtom 2 1,414 Jul-20-2022, 09:24 AM
Last Post: tomtom
  "ModuleNotFoundError: No module named 'PyQt5.QtWidgets'; 'PyQt5' is not a package" chipx 3 7,250 Dec-09-2021, 07:05 AM
Last Post: chipx
Question Setuptools CLI program ModuleNotFoundError after splitting up module into package Postbote 1 2,281 Nov-25-2021, 06:35 PM
Last Post: Postbote
  No Module found in other directory than source code [SOLVED] AlphaInc 1 2,008 Nov-10-2021, 04:34 PM
Last Post: AlphaInc
  pdfminer to csv mfernandes 2 2,784 Jun-16-2021, 10:54 AM
Last Post: mfernandes
  KafkaUtils module not found on spark 3 pyspark aupres 2 7,265 Feb-17-2021, 09:40 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020