Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install on Windows #16

Open
geauxtigers opened this issue Mar 17, 2018 · 33 comments
Open

Cannot install on Windows #16

geauxtigers opened this issue Mar 17, 2018 · 33 comments

Comments

@geauxtigers
Copy link

I am running Win10 with the anaconda dist of python 3.6 and have the MS build tools and compiler installed. I pip install the pdftotext package. Installation begins and then terminates with this message:

pdftotext.cpp(3): fatal error C1083: Cannot open include file: 'poppler/cpp/poppler-document.h': No such file or directory

Any ideas?

@jalan
Copy link
Owner

jalan commented Mar 17, 2018

You would need to get poppler and its development files installed on Windows. I don't use Windows, so I am not much help, sorry.

If you figure something out, I will gladly add it to the README here!

@geauxtigers
Copy link
Author

Thanks. I am researching this but have not found any good guidance. I will report back my findings.

@randiaz95
Copy link

Any updates on this problem? I happen to have this same thing.

@geauxtigers
Copy link
Author

No, I didn’t. My solution ended up being in a completely different direction, using different packages. This may be worth a mention in the README file for future Windows (10) users.

@jalan jalan changed the title Cannot Install on Windows 10 Cannot install on Windows May 20, 2018
@rcy222
Copy link

rcy222 commented Jun 25, 2018

All hope is not lost on the windows version. There is a command line utility with the same name and you can use the subprocess package to execute pdftotext

PDFtotext windows download instruction, credit @s2t2

  1. Go to https://www.xpdfreader.com/download.html and click "Download the Xpdf tools"
  2. Uncompress/extract the zip file, and move the folder to a location like the Desktop or the Programs directory.
  3. Inside the unzipped folder, copy the file bin64/pdftotext.exe into your project repository

@davidolmo
Copy link

3. Inside the unzipped folder, copy the file bin64/pdftotext.exe into your project repository

You mean that it can be used from windows command prompt but not python?

@GuodongQi
Copy link

GuodongQi commented Nov 27, 2018

  1. Inside the unzipped folder, copy the file bin64/pdftotext.exe into your project repository

You mean that it can be used from windows command prompt but not python?

just copy files bin64/*.exe to your PYTHON PATH directory,then it can be used both cmd and python shell

@Mattwmaster58
Copy link

Mattwmaster58 commented Jan 2, 2019

Any chance of prebuilt binaries being offered? Is it something that could be integrated into the CI setup? I think we'd need to build windows binaries on windows though, so moving to Appveyor would be required, unfortunately. Maybe a solution like cibuildwheel can help with that. I tried to, and failed miserably, at building it on windows.

Considering the only alternative at the moment (pdfminer and it's deraritives), which is super slow (4 orders of magnitude in my experience), inaccurate results which are in some cases impossible to parse accurately, I think It'd be great to offer prebuilt binaries with this functionality.

@woodsjs
Copy link
Contributor

woodsjs commented Sep 28, 2019

I "ugly" installed pdftotext successfully on windows three times over the past two days, as the subprocess method is a non-starter for me. I have a writeup on SO

https://stackoverflow.com/questions/45912641/unable-to-install-pdftotext-on-python-3-6-missing-poppler/58139729#58139729

as well as on my blog, which has screenshots

https://coder.haus/2019/09/27/installing-pdftotext-through-pip-on-windows-10/

Please try this, let me know if it works. I'm hoping to take time to do it properly and potentially generate a PR.

My solution requires Anaconda (for conda install). First, install Microsoft VC++ build tools, download poppler for windows as well as conda install poppler, and copy some of the poppler files to different locations in the Anaconda directory structure. Again, I have done this a total of 3 times and know it can be done better, but this will get you up and running.

@woodsjs
Copy link
Contributor

woodsjs commented Oct 1, 2019

The following fixes the issue on Windows 10.

Assumes MS VC++ Build Tools is installed.
Assumes Anaconda is being used.
Assumes Poppler is installed using conda install poppler.

The code update is in setup.py -

from os import path, getenv

if platform.system() in ['Windows']:
    conda_dir = getenv('CONDA_PREFIX')
    anaconda_poppler_include_dir = path.join(conda_dir, 'Library\include')
    anaconda_poppler_library_dir = path.join(conda_dir, 'Library\lib')
    include_dirs = [anaconda_poppler_include_dir]
    library_dirs = [anaconda_poppler_library_dir]

pip install completes successfully and the unit tests run successfully.

Let me know if this looks sane, and if I should create a PR for this.

@zacps
Copy link

zacps commented Oct 29, 2019

I needed to apply this diff, then it worked for me:

diff --git a/setup.py b/setup.py
index 4c0e861..8a7337a 100644
--- a/setup.py
+++ b/setup.py
@@ -29,8 +29,8 @@ elif platform.system() in ["Windows"]:
         print("ERROR: CONDA_PREFIX is not found.")
         print("       Install Anaconda or fix missing CONDA_PREFIX and try again.")
         sys.exit(1)
-    anaconda_poppler_include_dir = path.join(conda_dir, "Library\include")
-    anaconda_poppler_library_dir = path.join(conda_dir, "Library\lib")
+    anaconda_poppler_include_dir = path.join(conda_dir, r"Library\include")
+    anaconda_poppler_library_dir = path.join(conda_dir, r"Library\lib")
     include_dirs = [anaconda_poppler_include_dir]
     library_dirs = [anaconda_poppler_library_dir]
 else:

@jalan
Copy link
Owner

jalan commented Oct 31, 2019

@zacps I don't understand what your diff changes. Does it just change the strings into raw strings, or am I missing something? There are no escape characters, so aren't both versions equal?

$ python
>>> r"Library\include" == "Library\include"
True

@zacps
Copy link

zacps commented Oct 31, 2019

\i and \l are invalid escape sequences, but now that I think about it I'm not sure why it changed anything.

@Kagigz
Copy link

Kagigz commented Nov 20, 2019

Thank you so much @woodsjs for your blog post!

Just a quick update I would add:
When running pip install it's looking at the files inside my python3.6 libs folder and not the conda libs folder, so for me it worked when I copied the poppler-cpp.lib file into the AppData/Local/Programs/Python/Python36/libs folder.

@woodsjs
Copy link
Contributor

woodsjs commented Nov 21, 2019

Thanks for this, @Kagigz! I've updated the post to point to the possibility of the file living in the Python/Python{PythonVersion}/libs directory.

@jalan
Copy link
Owner

jalan commented Jan 7, 2020

@woodsjs I finally set up appveyor and pushed a release including your changes from #47: https://pypi.org/project/pdftotext/2.1.3/ . I hope it's nicer for Windows/conda users now. Thanks again!

@GadgetSteve
Copy link

@jalan It looks like you have yet to upload the Windows binaries to pypi so Windows users can get them!

@jalan
Copy link
Owner

jalan commented Jan 14, 2020

@GadgetSteve ?

I didn't say I was planning to upload any Windows binaries

@GadgetSteve
Copy link

" I finally set up appveyor and pushed a release including your changes from #47: https://pypi.org/project/pdftotext/2.1.3/ . I hope it's nicer for Windows/conda users now."

If you are not planning to upload any Windows binaries then the improvement for windows users is minimal - most do not have a compiler installed.

@palakjadwani
Copy link

palakjadwani commented Nov 21, 2020

I have had the hardest time installing pdftotext on my windows 10. Found @woodsjs page very useful as those were the exact errors I got. Finally I got it successfully installed but my PyCharm is not recognizing and giving :
ImportError: DLL load failed while importing pdftotext: The specified module could not be found.

I see inside site-packages that pip install doesn't download the jar file, maybe that is the problem. Please please someone help me out. Spent 2 days on this thing. @jalan

@GadgetSteve
Copy link

@palakjadwani this is the problem with there not being a binary download for the pdtotext package - you can find some workarounds at http://faculty.washington.edu/jwilker/559/2018/pdftotext.pdf but they are less than ideal.

@woodsjs
Copy link
Contributor

woodsjs commented Nov 22, 2020

@palakjadwani If you can see the package using the anaconda prompt (you can, correct?), this more than likely has NOTHING to do with the install of pdftotext. This is most likely because your pycharm install is not using the interpreter, conda, that you installed pdftotext under.

See Jetbrains documentation on changing your interpreter https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html?_ga=2.75189201.2125986240.1606050657-56391306.1606050657#interpreter You would add your existing anaconda environment.

I've tested this, as I do not use PyCharm, and was able to add my anaconda environment and get access to pdftotext. I would also suggest shutting pycharm down and restarting to make the new interpreter active.

@GodMakesMe
Copy link

I have the wheel file of the pdftotext for cp38 version 3.8.5 64 bit.
Just go to power shell and do
cd [Location of the file]
pip install ./[Wheel file [name]
Or
py -3.8 -m pip install ./[Wheel file name]

I am also attaching poppler files so you can extract these files in python destination folder.
pdftotext.zip

@GodMakesMe
Copy link

I have the wheel file of the pdftotext for cp38 version 3.8.5 64 bit.
Just go to power shell and do
cd [Location of the file]
pip install ./[Wheel file [name]
Or
py -3.8 -m pip install ./[Wheel file name]

I am also attaching poppler files so you can extract these files in python destination folder.
pdftotext.zip

If any one have the wheel of pdftotext of version cp39 64 bit kindly share it.

@GodMakesMe
Copy link

Now I have the latest wheel file. version 39 64 Bit
pdftotext.zip

@polyspastos
Copy link

Hey!

I have come across the following while trying to install it:

(venv) (dir)>python -m pip install ./pdftotext-2.1.5-cp39-cp39-win_amd64.whl
Processing (dir)\pdftotext-2.1.5-cp39-cp39-win_amd64.whl
Installing collected packages: pdftotext
Successfully installed pdftotext-2.1.5

(venv) (dir)>python (script).py
Traceback (most recent call last):
  File "(dir)\(script).py", line 11, in <module>
    import pdftotext
ImportError: DLL load failed while importing pdftotext: The specified module could not be found.

(venv) (dir)>pip freeze
(misc modules)
pdftotext @ file:///(drive):/(dir)/pdftotext-2.1.5-cp39-cp39-win_amd64.whl
(misc modules)

Do you have any idea what could be causing this?

Any help would be greatly appreciated.

@GodMakesMe
Copy link

GodMakesMe commented Jan 18, 2021 via email

@GadgetSteve
Copy link

GadgetSteve commented Jan 18, 2021 via email

@GodMakesMe
Copy link

GodMakesMe commented Jan 18, 2021

You can try latest version of poppler and extract the files according to the folders destination
And Then try installing pdftotext
If you are using anaconda then you can run
conda install -c conda-forge poppler
poppler-20.12.1-h31d4e15_3.zip

@ReMiOS
Copy link

ReMiOS commented Aug 5, 2021

I've had some trouble getting pdftotext working on Windows.
But i managed with the following steps:

download poppler: https://anaconda.org/conda-forge/poppler/21.03.0/download/win-64/poppler-21.03.0-h9ff6ed8_0.tar.bz2
copy the contents from ..\poppler-21.03.0-h9ff6ed8_0\Library\lib\ to ..<Python-install-folder>\libs
copy the contents from ..\poppler-21.03.0-h9ff6ed8_0\Library\include\poppler to ..<Python-install-folder>\include\poppler
copy the DLLs from ..\poppler-21.03.0-h9ff6ed8_0\Library\include\bin*.dll to ..<Python-install-folder>\Lib\site-packages\

Copy the DLLs to ..<Python-install-folder>\Lib\site-packages
charset.dll
freetype.dll
iconv.dll
libcrypto-1_1-x64.dll
libcurl.dll
liblzma.dll
libpng16.dll
libssh2.dll
openjp2.dll
tiff.dll
zlib.dll
zstd.dll

Now you can install pdftotext with:
pip install pdftotext-2.1.6-cp39-cp39-win_amd64.whl

Files are in attachment
Conda_Forge_DLL_x64.zip

P.S. It would be great if the Poppler PDF rendering library based would be upgraded from the xpdf-3.0 to the xpdf-4.03 code base.

@TheQuinbox
Copy link

Would needing to in stall Poppler also effect users of the software, if they're running a compiled application that uses this package?

@jalan
Copy link
Owner

jalan commented Oct 8, 2021

Would needing to in stall Poppler also effect users of the software, if they're running a compiled application that uses this package?

That depends on how you compile and distribute your application, of course. For example, on linux, you could bundle any needed shared libs with your app and start the app with an appropriate LD_LIBRARY_PATH set. I'm not a Windows developer, but I imagine there is something similar there.

@ReMiOS
Copy link

ReMiOS commented Oct 9, 2021

Using pyinstaller on Windows the Poppler DLLs are packed in the executable.

Using the poppler v21.10 the lcms2 DLL is needed (lcms color engine)
Link to Poppler: https://anaconda.org/conda-forge/poppler/21.10.0/download/win-64/poppler-21.10.0-h24fffdf_0.tar.bz2
Updated Wheel: pdftotext-2.2.1-cp39-cp39-win_amd64.whl.zip

Updated DLL package:
Conda_Forge_DLL_x64.zip
poppler.dll v21.10.0
poppler-glib.dll v21.10.0
poppler-cpp.dll v21.10.0
freetype.dll v2.10
zlib.dll v1.2.11
libssh2.dll v1.10.0
cairo.dll v1.16.0
libtiff.dll tiff.dll v4.3.0
libzstd.dll en zstd.dll v1.5.0
libcurl v7.79.1.0
openjp2.dll v2.4.0
iconv.dll en charset.dll v1.16
libpng16.dll v1.6.37
liblzma.dll v5.2.2
libcrypto-1_1-x64.dll v1.1.1l
lcms2.dll v2.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests