pymupdf / PyMuPDF

PyMuPDF is a high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents.
https://pymupdf.readthedocs.io
GNU Affero General Public License v3.0
5.43k stars 511 forks source link

Windows installation doesn't work if 64-bit Python is installed #39

Closed tyleri closed 8 years ago

tyleri commented 8 years ago

When installing PyMuPDF using setup.py, the installation will only work if the 32-bit version of Python is installed. If the 64-bit version is installed, there is an error running link.exe from Microsoft's Visual C++ for Python. This issue occurs on Windows 8.

JorjMcKie commented 8 years ago

Did you successfully generate MuPDF for x64 using your VS C++ ? Do you have the MuPDF *.lib files generated under x64? What exactly is the link error saying? We so far have tested PyMuPDF only under Python 32-bit versions (both Linux and WIndows) as far as I know - @rk700 ?

JorjMcKie commented 8 years ago

I have just been trying to build MuPDF for x64 from source using Visual Studio 2013. It did not work, at least on first try and based on the source download of MuPDF: several of the thridparty components for example refuse to get built for anything but x86 an architecture. So if you successfully built a MuPDF x64 version on your Windows system, I would certainly be interested in how you did that ...

rk700 commented 8 years ago

@JorjMcKie it works fine on my x86-64 Linux machine, and I agree that we should first figure out whether MuPDF can be built on a x86-64 Windows machine. So @tyleri could you please give us more information on that? Thanks.

tyleri commented 8 years ago

I was unable to build MuPDF using an x64 version of Python. I ended up installing the x86 version of Python to compile it. If needed, I can reinstall the x64 version and provide you with the error output.

JorjMcKie commented 8 years ago

Thank you for the information indeed! If I understood everything correctly, the situation is:

So we need to solve the issue with generating a x64 version of MuPDF on Windows first. Only afterwards we can investigate any potential issue with PyMuPDF.

@tyleri: Did I get you right?

I am certainly interested in generating MuPDF on x64-Windows. It must be possible in principle, because you find x64-binaries (mupdf.exe, mutool.exe etc.) for download on their website. If all fails, we can file a request for help or a bug to the MuPDF guys.

tyleri commented 8 years ago

I think that's correct. Installing works fine on 64bit-Windows if a 32bit-Python is installed, but not when 64bit-Python is installed.

tyleri commented 8 years ago

This may be obvious already, but if PyMuPDF is installed using 32bit-Python and then 64bit-Python is installed, the 64bit-Python cannot import the module.

image_20160111001

tyleri commented 8 years ago

I logged the error messages I get when installing PyMuPDF with 64bit-Python installed. I noticed that the vcvarsall.bat script referenced by python++.cmd can be provided with three different flags.

image_20160111002

Because of this, I tried changing the flag in python++.cmd to all three (none of the three worked), and logged each error message separately. Here's the gist with the logged error messages:

https://gist.github.com/tyleri/f7178cca1cf551e629a5

I also provided my python++.cmd file for reference (the only thing I changed in it is the directory, because Visual C++ For Python did not install in the directory originally referenced by python++.cmd).

Please let me know if you'd like any other information, and thank you for looking into this issue.

JorjMcKie commented 8 years ago

@tyleri everything depends on whether we can get x64 versions of libmupdf.lib and libthirdparty.lib. Once this is achieved, the remaining issues can be resolved by configuring one or the other script or bat file. So, x64 MuPDF must be generated first. I did not have the time yet to follow on on this. As I wrote earlier: when I naively tried to do this with my Visual Studio and the MuPDF source, it wouldn't work, because several third party components refused to get compiled under the Win x64 architecture.

JorjMcKie commented 8 years ago

@tyleri - I have managed to create a 64bit version - so far for Python 3.5 only. But Python 2.7 should not be a problem any longer. I have published a number of pre-generated PyMuPDF installation sets on the optional material repo. Using one of these requires no compile / no MuPDF download whatsoever, because they already contain the correct DLL _fitz.pyd for the respective Python version. Just yesterday I have created and successfully tested a 64bit version for Python 3.5. I will now do they same for 2.7. Please let me know whether you still are interested.

JorjMcKie commented 8 years ago

@tyleri - A minute ago I included a binary setup for PyMuPDF for Python 2.7 64bit version in the optional material repo. Please check whether you can install and use it. Thank you.

tyleri commented 8 years ago

I just installed PyMuPDF for Python 2.7 64-bit, and it worked perfectly! Thank you so much for your hard work on this.

JorjMcKie commented 8 years ago

Very pleased to hear this. Thank you for your prompt feedback. Have fun with it!