installing pyside using PIP - nmake not found

2019-08-07 18:51发布

I want to install PySide using PIP package manager. But it get this error message saying it didn't find nmake. This is no surprise because I do not have MSVC installed nor do I intend to.

Installing collected packages: pyside
  Running setup.py install for pyside
    Removing c:\users\cnyffele\appdata\local\temp\pip_build_cnyffele\pyside\pyside_package
    Python architecture is 32bit
    nmake not found. Trying to initialize the MSVC env...
    Searching MSVC compiler version 9.0
    error: Failed to find the MSVC compiler version 9.0 on your system.

However the setup.py program could simply run make:

C:\Users\cnyffele>where make
C:\MinGW32-xy\bin\make.exe

C:\Users\cnyffele>where mingw32-make
C:\MinGW32-xy\bin\mingw32-make.exe

But for some reason, it insists that if the platform is "win32" it should use msvc without trying anything else. It does, however, accept command-line options: I could specify "make-spec" to be "mingw" (see below).

From https://github.com/PySide/pyside-setup/blob/master/setup.py

OPTION_MAKESPEC = option_value("make-spec")

...

if sys.platform == "win32":
    if OPTION_MAKESPEC is None:
        OPTION_MAKESPEC = "msvc"
    if not OPTION_MAKESPEC in ["msvc", "mingw"]:
        print("Invalid option --make-spec. Available values are %s" % (["msvc", "mingw"]))
        sys.exit(1)

How can I make setyp.py use the correct make when installing with PIP? Is there a way to have PIP provide command-line options to setup.py when it runs it? If this is not possible, how can I run setup.py manually after PIP downloaded it?

1条回答
仙女界的扛把子
2楼-- · 2019-08-07 19:39

PIP allows passing options to setup via the options '--global-option' and '--install-option' as described in the pip reference guide.

The solution is:

pip install --global-option="--make-spec=mingw" PySide

Some additional information:

  • That prior to installing PySide using pip, you have to install cmake and Qt 4.8.
  • Build errors prevented me from downloading and installing PySide directly via pip. I needed to download the wheel binary packages from pypi.python.org.

Using a pre-downloaded .whl package, assuming the package is located in the current working directory:

pip install --global-option="--make-spec=mingw" PySide-1.2.4-cp27-none-win32.whl
查看更多
登录 后发表回答