在Windows 7 64位上运行“pip install numpy”时出现“错误:无法找到vcvarsall.bat”
我在 windows7 64bit
上运行 pip install numpy
,结果出现了一个错误:error: Unable to find vcvarsall.bat
。
我之前已经用 pip 安装了一些包,比如 pyzmq
、pysolr
、enum
等等,所以我真的不知道哪里出了问题。
唯一可能不同的地方是我安装了 .NET framework version 4.5
,我怀疑这可能是原因,因为在一些帖子里我看到这可能和 Visual Studio
有关(而我并没有安装它)。
完整的错误信息/追踪:
Downloading/unpacking numpy
Running setup.py (path:c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\setup.py) egg_info for package numpy
Running from numpy source directory.
warning: no files found matching 'tools\py3tool.py'
warning: no files found matching '*' under directory 'doc\f2py'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.pyd' found anywhere in distribution
Installing collected packages: numpy
Running setup.py install for numpy
non-existing path in 'numpy\\distutils': 'site.cfg'
F2PY Version 2
blas_opt_info:
blas_mkl_info:
libraries mkl,vml,guide not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
openblas_info:
libraries not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
atlas_blas_threads_info:
Setting PTATLAS=ATLAS
libraries ptf77blas,ptcblas,atlas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
atlas_blas_info:
libraries f77blas,cblas,atlas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
blas_info:
libraries blas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
blas_src_info:
NOT AVAILABLE
NOT AVAILABLE
non-existing path in 'numpy\\lib': 'benchmarks'
lapack_opt_info:
lapack_mkl_info:
mkl_info:
libraries mkl,vml,guide not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
NOT AVAILABLE
atlas_threads_info:
Setting PTATLAS=ATLAS
libraries ptf77blas,ptcblas,atlas not found in C:\Python27\lib
libraries lapack_atlas not found in C:\Python27\lib
libraries ptf77blas,ptcblas,atlas not found in C:\
libraries lapack_atlas not found in C:\
libraries ptf77blas,ptcblas,atlas not found in C:\Python27\libs
libraries lapack_atlas not found in C:\Python27\libs
numpy.distutils.system_info.atlas_threads_info
NOT AVAILABLE
atlas_info:
libraries f77blas,cblas,atlas not found in C:\Python27\lib
libraries lapack_atlas not found in C:\Python27\lib
libraries f77blas,cblas,atlas not found in C:\
libraries lapack_atlas not found in C:\
libraries f77blas,cblas,atlas not found in C:\Python27\libs
libraries lapack_atlas not found in C:\Python27\libs
numpy.distutils.system_info.atlas_info
NOT AVAILABLE
lapack_info:
libraries lapack not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
lapack_src_info:
NOT AVAILABLE
NOT AVAILABLE
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
build_src
building py_modules sources
building library "npymath" sources
No module named msvccompiler in numpy.distutils; trying from distutils
Running from numpy source directory.
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1521: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__)
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1530: UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
warnings.warn(BlasNotFoundError.__doc__)
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1533: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
warnings.warn(BlasSrcNotFoundError.__doc__)
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1427: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__)
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1438: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
warnings.warn(LapackNotFoundError.__doc__)
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1441: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
warnings.warn(LapackSrcNotFoundError.__doc__)
C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'define_macros'
warnings.warn(msg)
error: Unable to find vcvarsall.bat
Complete output from command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\zebra\\appdata\\local\\temp\\pip_build_zebra\\numpy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\zebra\appdata\local\temp\pip-py_oa_-record\install-record.txt --single-version-externally-managed --compile:
non-existing path in 'numpy\\distutils': 'site.cfg'
F2PY Version 2
blas_opt_info:
blas_mkl_info:
libraries mkl,vml,guide not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
openblas_info:
libraries not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
atlas_blas_threads_info:
Setting PTATLAS=ATLAS
libraries ptf77blas,ptcblas,atlas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
atlas_blas_info:
libraries f77blas,cblas,atlas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
blas_info:
libraries blas not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
blas_src_info:
NOT AVAILABLE
NOT AVAILABLE
non-existing path in 'numpy\\lib': 'benchmarks'
lapack_opt_info:
lapack_mkl_info:
mkl_info:
libraries mkl,vml,guide not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
NOT AVAILABLE
atlas_threads_info:
Setting PTATLAS=ATLAS
libraries ptf77blas,ptcblas,atlas not found in C:\Python27\lib
libraries lapack_atlas not found in C:\Python27\lib
libraries ptf77blas,ptcblas,atlas not found in C:\
libraries lapack_atlas not found in C:\
libraries ptf77blas,ptcblas,atlas not found in C:\Python27\libs
libraries lapack_atlas not found in C:\Python27\libs
numpy.distutils.system_info.atlas_threads_info
NOT AVAILABLE
atlas_info:
libraries f77blas,cblas,atlas not found in C:\Python27\lib
libraries lapack_atlas not found in C:\Python27\lib
libraries f77blas,cblas,atlas not found in C:\
libraries lapack_atlas not found in C:\
libraries f77blas,cblas,atlas not found in C:\Python27\libs
libraries lapack_atlas not found in C:\Python27\libs
numpy.distutils.system_info.atlas_info
NOT AVAILABLE
lapack_info:
libraries lapack not found in ['C:\\Python27\\lib', 'C:\\', 'C:\\Python27\\libs']
NOT AVAILABLE
lapack_src_info:
NOT AVAILABLE
NOT AVAILABLE
running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building py_modules sources
creating build
creating build\src.win-amd64-2.7
creating build\src.win-amd64-2.7\numpy
creating build\src.win-amd64-2.7\numpy\distutils
building library "npymath" sources
No module named msvccompiler in numpy.distutils; trying from distutils
Running from numpy source directory.
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1521: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__)
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1530: UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
warnings.warn(BlasNotFoundError.__doc__)
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1533: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
warnings.warn(BlasSrcNotFoundError.__doc__)
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1427: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__)
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1438: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
warnings.warn(LapackNotFoundError.__doc__)
c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy\numpy\distutils\system_info.py:1441: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
warnings.warn(LapackSrcNotFoundError.__doc__)
C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'define_macros'
warnings.warn(msg)
error: Unable to find vcvarsall.bat
----------------------------------------
Cleaning up...
Command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\zebra\\appdata\\local\\temp\\pip_build_zebra\\numpy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\zebra\appdata\local\temp\pip-py_oa_-record\install-record.txt --single-version-externally-managed --compile failed with error code 1 in c:\users\zebra\appdata\local\temp\pip_build_zebra\numpy
Storing debug log for failure in C:\Users\zebra\pip\pip.log
6 个回答
在我的Windows 7 64位系统和Python 2.7上,有一个方法可以直接从Sourceforge下载numpy的安装文件。比如说,下载文件名为numpy-1.9.2-win32-superpack-python2.7.exe。
然后可以用7z这样的工具来解压这个EXE文件。解压后会得到三个EXE文件,比如numpy-1.9.2-nosse.exe、numpy-1.9.2-sse2.exe和numpy-1.9.2-sse3.exe。
现在选择一个合适的文件。对于大多数现代处理器来说,选择SSE3的那个就可以了。
SciPy的安装方法和这个一样:SF链接
如果你觉得这些安装文件可以用,那么唯一的缺点就是你不能通过pip来更新这些包。
对于64位系统,这个问题可以通过以下五个步骤来解决。 (内容来自 http://springflex.blogspot.in/2014/02/how-to-fix-valueerror-when-trying-to.html)
- 下载 vcsetup.exe(Visual Studio 2008 Express 安装程序),并从以下链接安装: go.microsoft.com/?linkid=7729279
从以下链接安装 Microsoft Windows SDK: http://www.microsoft.com/en-us/download/details.aspx?id=24826
在安装说明中选择网页安装链接以获取安装程序。
运行安装程序文件,如果不需要示例和文档,可以取消选择这些选项。
在文件夹 "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\" 中创建一个名为 "vcvarsamd64.bat" 的批处理文件副本,并重命名。
将 "vcvarsamd64.bat" 文件复制并粘贴到 "C:\Program Files (x86)\Microsoft Visual Studio 9.0/VC/bin/amd64" 文件夹中。
你需要下载并安装 vcsetup.exe(Visual C++ 2008 Express 版)这个文件。
然后,把新创建的 vcvarsall.bat 文件的路径添加到 "PATH" 环境变量中。
添加后,确保你的 PATH 环境变量里没有特殊符号。
我在64位的Windows系统上也遇到了同样的问题。这个问题通过安装Microsoft Visual C++ Compiler for Python 2.7解决了。微软对这个工具的描述是:
这个软件包包含了编译器和一组系统头文件,这些是用来生成Python包的二进制轮子(binary wheels)的。Python包的二进制轮子可以在任何Windows系统上安装,而不需要访问C编译器。
如果你需要这个编译器包,通常会收到的错误信息是找不到vcvarsall.bat
...
效果非常好。
也许你可以在这里使用现成的二进制文件:http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy?用pip安装可能效果不好。原因是numpy根本不能用Visual Studio编译,需要用gcc来构建。
如果你还是想自己编译numpy,你需要设置一个Linux机器,使用Vagrant,并按照这里的官方构建说明进行操作:https://github.com/juliantaylor/numpy-vendor