Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
329 views
in Technique[技术] by (71.8m points)

python - Compiler problems with pip during numpy install under Windows 8.1, 7 Enterprise and 7 Home Editions

I am unable to install numpy via pip install numpy on my computer running Python 3.4 due to various errors I receive linked to compilation issues (This is only the case on a 64-bit installation of Python).

This is a problem that has been reported extensively and I had a related question about unable to find vcvarsall.bat. I have tested this on three different clean machines running Windows 8.1, 7 Enterprise and 7 Home Editions and it always comes up.

Installing Visual Studio 2010 Express C++ gets rid of the first error in the link - i.e. Unable to find vcvarsall.bat but throws out a next exception ending with a ValueError as here:

  File "C:Python34libdistutilsmsvc9compiler.py", line 371, in initialize

    vc_env = query_vcvarsall(VERSION, plat_spec)

  File "C:Python34libdistutilsmsvc9compiler.py", line 287, in query_vcvarsall

    raise ValueError(str(list(result.keys())))

ValueError: ['path']

I have then followed this advice and patched the file as linked in the discussion forum which resulted in a KEY_BASE error.

  File "C:UsersMatejAppDataLocalTemppip_build_Matej
umpy
umpydistutilscommandconfig.py", line 18, in <module>

    from numpy.distutils.mingw32ccompiler import generate_manifest

  File "C:UsersMatejAppDataLocalTemppip_build_Matej
umpy
umpydistutilsmingw32ccompiler.py", line 36, in <module>

    from distutils.msvccompiler import get_build_version as get_build_msvc_version

  File "C:Python34libdistutilsmsvccompiler.py", line 638, in <module>

    from distutils.msvc9compiler import MSVCCompiler

  File "C:Python34libdistutilsmsvc9compiler.py", line 71, in <module>

    r"v%sA"

  File "C:Python34libdistutilsmsvc9compiler.py", line 67, in <listcomp>

    WINSDK_PATH_KEYS = [KEY_BASE + "Microsoft SDKs\Windows" + rest for rest in (

NameError: name 'KEY_BASE' is not defined

Following the advice in the same link, I have added the following definition of KEY_BASE before the variable gets called in msvc9compiler.py:

KEY_BASE = r"SoftwareMicrosoft"

Which results in the final error I was not able to troubleshoot:

  File "C:UsersMatejAppDataLocalTemppip_build_Matej
umpy
umpydistutilscommanduild_src.py", line 164, in build_sources

    self.build_library_sources(*libname_info)

  File "C:UsersMatejAppDataLocalTemppip_build_Matej
umpy
umpydistutilscommanduild_src.py", line 299, in build_library_sources

    sources = self.generate_sources(sources, (lib_name, build_info))

  File "C:UsersMatejAppDataLocalTemppip_build_Matej
umpy
umpydistutilscommanduild_src.py", line 386, in generate_sources

    source = func(extension, build_dir)

  File "numpycoresetup.py", line 682, in get_mathlib_info

    raise RuntimeError("Broken toolchain: cannot link a simple C program")

RuntimeError: Broken toolchain: cannot link a simple C program

I have tried the following but none of it resolved the Broken toolchain error:

  • This link that includes a further patch to msvc9compiler.py
  • This link by Peter Cock (This helps on the 32-bit install of Python3.4)
  • Tried installing using easy_install as some users suggested it might work that way

NOTE 1: I am aware of the workaround using the compiled binaries on this website I am specifically looking for solution using distutils if there is one. NOTE 2: The error logs are obviously larger and I cut them for readability.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I was able to reproduce all these errors in Windows 7 Professional (64 bit).

Your final issue (Broken toolchain) is caused by more manifest related issues. I was able to work around this by changing the following line (in msvc9compiler.py):

mfinfo = self.manifest_get_embed_info(target_desc, ld_args)

to

mfinfo = None

thus bypassing the if statement which immediately follows. After this change numpy successfully compiled for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...