解決Unable to find vcvarsall.bat的辦法

來源:互聯網
上載者:User

基本環境:
1.python34
2.win32系統
3.VisualStudio 2008

使用easy_install安裝numpy時,提示:
“error: Setup script exited with error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat).”
根據網上的資料查看C:\Python34\Lib\distutils\msvc9compiler.py的內容
該檔案通過檢索註冊表來找到vcvarsall.bat的安裝目錄,該檔案檢索的註冊表路徑為
‘Software\Microsoft\VisualStudio\10.0\SETUP\VC’,擷取其下的登錄機碼:ProductDir對應的值

本機環境已安裝了vs 2008,對應的註冊表路徑為’Software\Microsoft\VisualStudio\9.0\SETUP\VC’

通過修改C:\Python34\Lib\distutils\msvc9compiler.py中第187行:

return majorVersion + minorVersion

改為

return 9.0

這次出現新的錯誤:
File “C:\Python34\lib\distutils\msvc9compiler.py”, line 287, in query_vcvarsall
raise ValueError(str(list(result.keys())))
ValueError: [‘path’]

查看query_vcvarsall函數,這個函數是在尋找系統內容變數

interesting = set(("include", "lib", "libpath", "path"))

環境變數得包含這四種,少了都會報錯
繼續研究代碼,發現py在找這幾個檔案(352行)

self.cc = "cl.exe"self.linker = "link.exe"self.lib = "lib.exe"self.rc = "rc.exe"self.mc = "mc.exe"

找到這幾個檔案的路徑,並建立環境變數
lib=C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\
libpath=C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\
include=C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\

繼續出現新的錯誤:
File “numpy\core\setup.py”, line 686, in get_mathlib_info
RuntimeError: Broken toolchain: cannot link a simple C program

最後請下載numpy-1.9.2-win32-superpack-python3.4.exe進行安裝,這次很順利,一次成功

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.