Windows + virtualenv + pip + NumPy(安装NumPy时出现问题)

26

在 Windows 上,我通常只使用二进制安装程序,但这次我想在虚拟环境中安装 NumPy,因此我创建了一个虚拟环境:

virtualenv --no-site-packages --distribute summary_python
cd summary_python/Scripts
activate.bat

然后我尝试安装NumPy

pip install numpy

我遇到了一个错误。我的pip.log文件内容如下:

Downloading/unpacking numpy
  Running setup.py egg_info for package 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:\Users\fname.lname\Documents\summary_python\lib
      libraries mkl,vml,guide not found in C:\
      NOT AVAILABLE

    atlas_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in c:\Users\fname.lname\Documents\summary_python\lib
      libraries ptf77blas,ptcblas,atlas not found in C:\
      NOT AVAILABLE

    atlas_blas_info:
      libraries f77blas,cblas,atlas not found in c:\Users\fname.lname\Documents\summary_python\lib
      libraries f77blas,cblas,atlas not found in C:\
      NOT AVAILABLE

    blas_info:
      libraries blas not found in c:\Users\fname.lname\Documents\summary_python\lib
      libraries blas not found in C:\
      NOT AVAILABLE

    blas_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    lapack_opt_info:
    lapack_mkl_info:
    mkl_info:
      libraries mkl,vml,guide not found in c:\Users\fname.lname\Documents\summary_python\lib
      libraries mkl,vml,guide not found in C:\
      NOT AVAILABLE

      NOT AVAILABLE

    atlas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in c:\Users\fname.lname\Documents\summary_python\lib
      libraries lapack_atlas not found in c:\Users\fname.lname\Documents\summary_python\lib
      libraries ptf77blas,ptcblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\
    numpy.distutils.system_info.atlas_threads_info
      NOT AVAILABLE

    atlas_info:
      libraries f77blas,cblas,atlas not found in c:\Users\fname.lname\Documents\summary_python\lib
      libraries lapack_atlas not found in c:\Users\fname.lname\Documents\summary_python\lib
      libraries f77blas,cblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\
    numpy.distutils.system_info.atlas_info
      NOT AVAILABLE

    lapack_info:
      libraries lapack not found in c:\Users\fname.lname\Documents\summary_python\lib
      libraries lapack not found in C:\
      NOT AVAILABLE

    lapack_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    running egg_info
    running build_src
    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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:531: UserWarning: Specified path  is invalid.
      warnings.warn('Specified path %s is invalid.' % d)
    c:\Users\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1417: 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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1426: 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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1429: 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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1333: 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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1344: 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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1347: 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__)
    error: Unable to find vcvarsall.bat
    Complete output from command python setup.py egg_info:
    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:\Users\fname.lname\Documents\summary_python\lib

  libraries mkl,vml,guide not found in C:\

  NOT AVAILABLE



atlas_blas_threads_info:

Setting PTATLAS=ATLAS

  libraries ptf77blas,ptcblas,atlas not found in c:\Users\fname.lname\Documents\summary_python\lib

  libraries ptf77blas,ptcblas,atlas not found in C:\

  NOT AVAILABLE



atlas_blas_info:

  libraries f77blas,cblas,atlas not found in c:\Users\fname.lname\Documents\summary_python\lib

  libraries f77blas,cblas,atlas not found in C:\

  NOT AVAILABLE



blas_info:

  libraries blas not found in c:\Users\fname.lname\Documents\summary_python\lib

  libraries blas not found in C:\

  NOT AVAILABLE



blas_src_info:

  NOT AVAILABLE



  NOT AVAILABLE



lapack_opt_info:

lapack_mkl_info:

mkl_info:

  libraries mkl,vml,guide not found in c:\Users\fname.lname\Documents\summary_python\lib

  libraries mkl,vml,guide not found in C:\

  NOT AVAILABLE



  NOT AVAILABLE



atlas_threads_info:

Setting PTATLAS=ATLAS

  libraries ptf77blas,ptcblas,atlas not found in c:\Users\fname.lname\Documents\summary_python\lib

  libraries lapack_atlas not found in c:\Users\fname.lname\Documents\summary_python\lib

  libraries ptf77blas,ptcblas,atlas not found in C:\

  libraries lapack_atlas not found in C:\

numpy.distutils.system_info.atlas_threads_info

  NOT AVAILABLE



atlas_info:

  libraries f77blas,cblas,atlas not found in c:\Users\fname.lname\Documents\summary_python\lib

  libraries lapack_atlas not found in c:\Users\fname.lname\Documents\summary_python\lib

  libraries f77blas,cblas,atlas not found in C:\

  libraries lapack_atlas not found in C:\

numpy.distutils.system_info.atlas_info

  NOT AVAILABLE



lapack_info:

  libraries lapack not found in c:\Users\fname.lname\Documents\summary_python\lib

  libraries lapack not found in C:\

  NOT AVAILABLE



lapack_src_info:

  NOT AVAILABLE



  NOT AVAILABLE



running egg_info

running build_src

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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:531: UserWarning: Specified path  is invalid.

  warnings.warn('Specified path %s is invalid.' % d)

c:\Users\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1417: 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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1426: 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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1429: 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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1333: 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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1344: 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\fname.lname\Documents\summary_python\build\numpy\numpy\distutils\system_info.py:1347: 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__)

error: Unable to find vcvarsall.bat

----------------------------------------
Command python setup.py egg_info failed with error code 1
Exception information:
Traceback (most recent call last):
  File "c:\Users\fname.lname\Documents\summary_python\lib\site-packages\pip-1.0.1-py2.7.egg\pip\basecommand.py", line 126, in main
    self.run(options, args)
  File "c:\Users\fname.lname\Documents\summary_python\lib\site-packages\pip-1.0.1-py2.7.egg\pip\commands\install.py", line 223, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "c:\Users\fname.lname\Documents\summary_python\lib\site-packages\pip-1.0.1-py2.7.egg\pip\req.py", line 986, in prepare_files
    req_to_install.run_egg_info()
  File "c:\Users\fname.lname\Documents\summary_python\lib\site-packages\pip-1.0.1-py2.7.egg\pip\req.py", line 222, in run_egg_info
    command_desc='python setup.py egg_info')
  File "c:\Users\fname.lname\Documents\summary_python\lib\site-packages\pip-1.0.1-py2.7.egg\pip\__init__.py", line 255, in call_subprocess
    % (command_desc, proc.returncode))
InstallationError: Command python setup.py egg_info failed with error code 1
3个回答

48

我成功地将NumPy二进制文件安装到虚拟环境中,使用了老旧的easy_install和一点解压魔法。

你从SourceForge下载的numpy-1.x.x-win32-superpack-python2.x.exe实际上只是一个薄包装,包含了三个独立的二进制发行版(根据您的CPU功能启用SSE3SSE2或未启用SSE)。如果您在7-Zip(或其他存档实用程序)中打开超级包EXE文件,则可以提取这些单独的设置文件以便单独使用。

然后,激活您的虚拟环境,并运行

easy_install c:\path\to\extracted\numpy-1.x.x-sse3.exe

例如,要安装SSE3优化的二进制文件,可以使用easy_install。它足够智能,可以在wininst包中找到所有需要的内容,并将编译好的egg提取到您的虚拟环境的site-packages文件夹中。我也可以确认,当您这样做时,pip仍然能够识别和/或卸载NumPy,并且使用pip安装依赖于NumPy的其他软件包也可以正常工作。

唯一的问题是知道使用哪个优化级别(SSE3、SSE2还是无SSE)。如果您有一个相对较新的处理器(比如说,比Pentium 4Athlon 64更新),那么选择完整的SSE3可能是安全的。您也可以运行测试套件来确认一切都按预期工作。


我发现easy_install“技巧”非常有用,可以将各种二进制软件包安装到虚拟环境中。即使我在计算机上已经设置好了所有必要的编译器,但通常使用官方发布的版本更容易/更快/更安全。


为了让 pandas 正常工作,我不得不手动升级,但现在一切都正常了。 "pip install pandas --upgrade" - user913059

4

由于pip只能从源代码安装,您需要设置来构建和编译NumPy才能使用pip。我从未尝试过这个。

最近我在Windows 7的虚拟环境中获取SciPyMatplotlib的方法是将目录和egg文件从我的常规Python安装直接复制到虚拟环境中。对于Matplotlib,我还成功地将二进制安装程序直接解压缩到virtualenv中(我仅尝试了Python 3.2的Gohlke安装程序)。

我曾经成功地easy_install NumPy到虚拟环境中,使用的是一个二进制发布版,但这一次我没有成功(NumPy 1.5.1)。

有人推荐http://pypi.python.org/pypi/pyg,它应该允许从二进制包安装到虚拟环境中,但我还没有尝试过。


谢谢!我尝试了Pyg,但没有成功。我会定期回来检查。 - oob

0

我不需要解压 .exe 文件的技巧。我只需激活我的虚拟环境,然后:

easy_install numpy

值得使用virtualenvwrapper这个额外的工具,它非常棒。通过'workon'命令激活它。文档在这里-> http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html#controlling-the-active-environment - miguelfg

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接