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

Setup.py compile on Win 7 without Visual Studio installed. #42

Closed
gbarnabic opened this issue Mar 4, 2016 · 25 comments
Closed

Setup.py compile on Win 7 without Visual Studio installed. #42

gbarnabic opened this issue Mar 4, 2016 · 25 comments

Comments

@gbarnabic
Copy link

I followed the directions:

if you have not installed Visual Studio or if you do not want to generate MuPDF, you must download PyMuPDF Optional Material now and unzip / decompress its content in directory ./PyFitz/PyMuPDF-optional-material. This optional material contains the lib files needed for PyMuPDF generation, and the MuPDF header files. Update setup.py, parameter include_dirs, to point to these header files.

I don't have Python 2.7 installed on the computer either if that has anything to do with it.

Here is what I get:
G:\pyfitz>python setup.py install
running install
running build
running build_py
running build_ext
building 'fitz._fitz' extension
error: Unable to find vcvarsall.bat

I do end up with g:\pyfitz\build_init_.py, fitz.py, utils.py but no _fitz.pyd

@JorjMcKie
Copy link
Collaborator

My system is WIn 10 (x64), Python 2.7 (win32) and Visual Studio 2013. I have successfully generated MuPDF with this VS 2013, from where the *.lib files in the optional-material-repo were taken.

Your error message above error: Unable to find vcvarsall.bat is a very common error on Windows systems - and of course has its fixes ... For this purpose I am using a Windows cmd / bat script, that ensures correctly pointing to the libraries of the required C++ compiler: python++.cmd. I think it also is contained in the repo of the optional materials.

What is your Python version? I have just communicated with someone using Win 8.1 (x64) / Python 3.4 (win32), who generated MuPDF and then PyMuPDF successfully using Visual Studio.

@JorjMcKie
Copy link
Collaborator

Just confirming: python++.cmd is contained in optional materials. Generating PyMuPDF (or any other C extension) would then go like so:

python++ setup.py install

instead of just invoking python setup.py install.
The directory references inside the python++.cmd to MS Win C libraries would of course have to be adjusted accordingly.

@gbarnabic
Copy link
Author

I'm not sure if this is what you wanted me to try but here is the terminal copy and paste:

G:\pyfitz>g:\pyfitz\PyMuPDF-optional-material\utility\python++ setup.py install
The system cannot find the path specified.
'vcvarsall.bat' is not recognized as an internal or external command,
operable program or batch file.
running install
running build
running build_py
running build_ext
building 'fitz._fitz' extension
creating build\temp.win32-3.4
creating build\temp.win32-3.4\Release
creating build\temp.win32-3.4\Release\fitz
cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IG:/pyfitz/PyMuPDF-optional-materia
l/MuPDF/include -IG:/pyfitz/PyMuPDF-optional-material/MuPDF//include/mupdf -IG:
Python34\include -IG:\Python34\include /Tc./fitz/fitz_wrap.c /Fobuild\temp.win32
-3.4\Release./fitz/fitz_wrap.obj
error: command 'cl.exe' failed: No such file or directory

(note: turning in for the night, I'll try again tomorrow.)

@gbarnabic
Copy link
Author

Win 8.1 64 bit. Only Python 3.4 installed in a G:\Python34 directory. No Visual Studio installed.

@rk700
Copy link
Contributor

rk700 commented Mar 4, 2016

Though I don't have a Windows machine, but it seems that you might have to install VS first since the compiler/linker are required.

@gbarnabic
Copy link
Author

Ok, so despite what the directions here say. I apparently have to install VS in order to get PyMuPDF to install on my computer. Sorry for this stupid question but I assume that is only necessary to compile the package. Once it is compiled I will be able to deploy the application with something like Py2exe without the requirement that the client computer have VS installed, correct?

@JorjMcKie
Copy link
Collaborator

@gbarnabic - you do need a C / C++ compiler to install PyMuPDF. The error in your generation log (cl.exe missing) says that your Python installation does not know the whereabouts of your C / C++ compiler / linker.

You do not need Visual Studio, if you have the MuPDF libraries libmupdf.lib and thirdparty.lib available on your machine, which must be compatible to your Python version. The *.lib files provided in the optional material of PyMuPDF are for Python 2.7, they will not work for Python 3.x - I need to clarify this fact in the installation instructions.

I am working on a Python 3.x version for those 2 libs.

In your case (Python 3.4), I am afraid you must generate MuPDF yourself using Visual Studio for the time being.

@gbarnabic
Copy link
Author

OK, now I understand. I'm working on a few other things so I'll hold off for a while on installing VS on my Win8 machine. Hopefully by the time I get back to it, you will have gotten a chance to get those 3.4 versions of the .lib files uploaded somewhere. If not I'll have to clear up some space and do the VS install.

@JorjMcKie
Copy link
Collaborator

@gbarnabic - I have created *.lib files for Python 3.x. They are contained in directory Lib34Win32 of the optional material repo. Documentation has also been updated. It was quite an experience, I can tell ... look at the bottom to see an overview.
In your case, you need a VC++ compiler version MSVC 10.0 to generate PyMuPDF under Python 3. You either can get it by downloading VS Communty 2013 (hm, hm, ...), or by downloading the much smaller (< 600 MB) Windows 7 SDK - have a look at the docs.

  1. In order to use pre-generated lib files, you must use a C compiler compatible to them. So, lib's generated under MSVC 9.0 (also used by Pyton 2.7) cannot be linked to PyMuPDF for Python 3.
  2. Luckily, Python major version numbers often use the same compiler. So, what was generatable under 3.3, can also be generated under 3.4. A setup.py install is however required, because the respective python??.dll file is being bound in by the setup process.
  3. Python 3.5 is not supported yet. This version does use a different VC++ compiler (VS2015 / MSVC 14.0). I was able to generate the lib files, but the MSVC 14.0 compiler version unexpectedly refuses to compile our interface file fitz_wrap.c. I am investigating this.
  4. Generally, alternative, Non-MS compilers (e.g. MinGW) can nowadays be used to create extensions like PyMuPDF. MinGW-gcc for example has no problem compiling PyMuPDF under Python 3.5. I am investigating this too, because the current incompatibilities between Python 2 and Python 3 lib file versions seem artificial to me. Ideally, I should be able to create lib's only once (they are written in C and know nothing about Python) and reuse them across arbitrary Python versions. While MinGW-gcc does compile PyMuPDF, it has a problem linking VS pre-generated lib files ("unknown file format"). So I need to figure out a way to generate my lib's using gcc from the start ...

@gbarnabic
Copy link
Author

Wow, you have done a lot of work on this. The bad news is that I am on Windows 8.1. The Win 7 SDK failed to install. I found the 8.1 SDK https://dev.windows.com/en-us/downloads/windows-8-1-sdk but it says it does not come with the compiler anymore. So it appears that I have no choice but to install VS 2013. So... I downloaded the VS 2013 Community version... I have 7 gig left on my C: drive but 1.28 TB on my G: drive. Unfortunately the shitty install that MS provides tells me that it requires "9 GB across all drives." Despite me telling it to install on my G: drive it will not install saying I need to free up more space. It looks like getting this to install is not meant to be for me.

@JorjMcKie
Copy link
Collaborator

How unfortunate!
Well,as I said, I am working on a MinGW-based installation of MuPDF and PyMuPDF.
In the meantime I can offer to send you the generated files of my Python 3.4 PyMuPDF.
It's just the content of directory C:\Python34\Lib\site-packages\fitz (10 MB, or 5 MB UPX-compressed).
If you take it and copy it to this location on your machine, it should run immediately.
Just let me know.

@JorjMcKie
Copy link
Collaborator

@gbarnabic - here are some good news that may interest you:
I have created a binary installation script for PyMuPDF. Take the ZIP file in the new directory install34 of the optional material, unzip it anywhere you want and perform a python setup.py install.
This requires no compilation / generation whatsoever - it just copies everything to the site-packages folder of your Python 3.4.

@gbarnabic
Copy link
Author

Success!!! I have no idea of your location on this planet but I do owe you a dinner or something. It worked like a charm. Much thanks for putting in all the work on my specific issue. Hopefully someone else will benefit as well.

@JorjMcKie
Copy link
Collaborator

Great - glad to hear that.
By the way, since my retirement, I am living in Venezuela.
But you owe me nothing - on the contrary: thank you for your patience!
With your input, this piece of software has become better.
Anything that reduces / removes inhibitors will lead to a greater acceptance - this is what I have learned from our communication.

Should you ever plan to come to this country (more specifically, Isla de Margarita), let's make sure we meet ...

@gbarnabic
Copy link
Author

You never know. I took a quick look at Isla de Margarita and it looks very nice. I'm actually off to Buenos Aires Argentina in a few weeks for a 2 week cruise around Cape Horn and up along the Chile coast. I've never been to Venezuela. Drop me an email with your info. My email is the name I use here @gmail.com.

@liaicheng
Copy link

HI,I got the same issue when installed.
first, i can't get any info from google about python++, :(
I build the mupdf with visual stadio 2015, and put the lib into Pyfitz like below:
image

error: Unable to find vcvarsall.bat
occured.
anything wrong? thanks!

@JorjMcKie
Copy link
Collaborator

@liaicheng
python++.bat is my own little helper, you cannot find it anywhere on the internet. Its source code follows.

You need this type of helpers on Windows, if your C compiler is not the one that your Python installation expects. In that case you always must provide your own information on where to find all the libraries.

Unfortunately this is always a mess on Windows ... this was my motivation to prepare PyMuPDF installation binaries for the plagued Windows users :-)

Here is the source of python++.bat to compile / generate Python 2.7 32bit extensions. Other Python versions and / or Visual Studio versions of course require changes. To be invoked exactly like python setup.py ... - except you use python++ instead of python.

@echo off
REM adjust the following to your VS version ...
PUSHD "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python"
call vcvarsall.bat x86
SET DISTUTILS_USE_SDK=1
SET MSSdk=1
POPD
python %*

In order to avoid Python setup and Visual Studio making the wrong assumptions, I am currently using this type of script to generate PyMuPDF for several Python versions. The compile and link stepts are exactly what a setup.py generates, but it gives me the flexibility to adjust to Python versions.

gen-PyMuPDF.txt

Hope it helps ...

@liaicheng
Copy link

I used the binary installation, but it seems that gets CJK front problom
https://github.com/rk700/PyMuPDF/wiki/Windows-Binaries-Installation
image

@JorjMcKie
Copy link
Collaborator

OK - then this should be a separate new issue.

These are just warnings.

Are you actually experiencing that text is not reproduced correctly (e.g. in pixmaps or text output)? I have tested text with Chinese charatcers and found no problems. I do get this type of warnings a lot myself ...

@liaicheng
Copy link

@JorjMcKie Thanks for your respones! :)
It seems i have to install with the way ''https://github.com/rk700/PyMuPDF/wiki/Windows-Binaries-Generation'
Something wrong , i would check it step by step now, hope it can work then.

@JorjMcKie
Copy link
Collaborator

example with a PDF containing Chinese and Latin characters:
grafik

This is how the generated text file looks like:
grafik

@liaicheng
Copy link

you can check that file:https://ufile.io/9afc8
some pdf parse tool can't handle it, like pdfminer, or pdf2json.
hope pymupdf can handle.

@JorjMcKie
Copy link
Collaborator

well, would you agree that my above example is sufficient?

If not, I can change config.h in the MuPDF includes such, that more fonts are supported.

So, I am sure we will find a solution.

Keep in touch.

@liaicheng
Copy link

thanks, @JorjMcKie ,the example is sufficient!
i hope you can offer binary installation with all front, because util now, i still can't install it correctly..

@JorjMcKie
Copy link
Collaborator

@liaicheng I am going to open another issue and talk to you from there.
Your topic clearly is not a PyMuPDF installation topic, and besides we are discussing inside a thread that has been closed a year ago ...
See you from the new issue.

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

4 participants