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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6114115/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:55:31  来源:igfitidea点击:

Windows + virtualenv + pip + NumPy (problems when installing NumPy)

pythonwindowsnumpypipvirtualenv

提问by oob

On Windows, I normally just use the binary installer, but I would like to install NumPyonly in a virtualenv this time, so I created a virtual env:

在 Windows 上,我通常只使用二进制安装程序,但这次我只想在 virtualenv 中安装NumPy,所以我创建了一个虚拟 env:

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

Then I tried to install NumPy

然后我尝试安装 NumPy

pip install numpy

And I get an error. My pip.log is pasted below:

我得到一个错误。我的 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

回答by Greg Haskins

I've had success installing NumPy binaries into a virtualenv with good 'ol easy_installand a little bit of un-archiving magic.

我已经成功地将 NumPy 二进制文件安装到虚拟环境中,easy_install并具有良好的 'ol和一些取消归档魔法。

The numpy-1.x.x-win32-superpack-python2.x.exerelease you download from SourceForgeis really just a thin wrapper around three separate binary distributions (with SSE3, SSE2, or no SSE enabled, depending on the capabilities of your CPU). If you open up the superpack EXE file in 7-Zip(or another archive utility), you can extract those individual setup files somewhere to use separately.

numpy-1.x.x-win32-superpack-python2.x.exe您从SourceForge下载的发行版实际上只是围绕三个单独的二进制发行版(启用SSE3SSE2或不启用 SSE,具体取决于您的 CPU 的功能)的薄包装。如果您在7-Zip(或其他存档实用程序)中打开 superpack EXE 文件,您可以将这些单独的安装文件解压缩到某处以单独使用。

Then, activate your virtual environment, and run

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

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

to install the SSE3-optimized binaries, for example. easy_installis smart enough to find everything it needs inside that wininstbundle and will extract the compiled egginto your virtualenv's site-packages folder. I can also confirm that pip is still able to recognize and/or uninstall NumPy when you do this, and that using pip to install other packages which depend on NumPy works just fine.

例如,安装 SSE3 优化的二进制文件。easy_install足够聪明,可以在该wininst包中找到它需要的所有内容,并将编译后的提取到您的 virtualenv 的 site-packages 文件夹中。我还可以确认,当您执行此操作时 pip 仍然能够识别和/或卸载 NumPy,并且使用 pip 安装依赖于 NumPy 的其他软件包工作正常。

The only catch is knowing which optimization level to use (SSE3, SSE2, or no-SSE). If you have a reasonably modern processor(newer than, say, a Pentium 4or Athlon 64), it's probably safe to go with the full SSE3. You can probably also run the test suite to confirm everything works as expected.

唯一的问题是知道要使用哪个优化级别(SSE3、SSE2 或 no-SSE)。如果您有一个相当现代的处理器(比Pentium 4Athlon 64 新),那么使用完整的 SSE3 可能是安全的。您也可以运行测试套件以确认一切正常。



I've found the easy_install"trick" to be really useful for installing all sorts of binary packages into a virtualenv. Even though I have all the requisite compilers set up on my machine, it's usually easier/faster/safer to stick with the official release when one is provided.

我发现easy_install“技巧”对于将各种二进制包安装到 virtualenv 中非常有用。尽管我在我的机器上设置了所有必需的编译器,但在提供官方版本时坚持使用官方版本通常更容易/更快/更安全。

回答by Josef

Since pip can only install from source, you need to have the setup to build and compile NumPyto be able to use pip. I never tried this.

由于 pip 只能从源代码安装,因此您需要进行设置以构建和编译NumPy才能使用 pip。我从来没有试过这个。

What I did recently to get NumPy, SciPyand Matplotlibinto a virtual environment on Windows 7 is to copy the directories and eggfiles from my regular Python install directly into the virtual environment. For Matplotlib I also managed to unzip the binary installer directly into the virtualenv (I only tried this for the Gohlke installer for Python 3.2).

我最近为将 NumPy、SciPyMatplotlib引入 Windows 7 上的虚拟环境所做的是将常规 Python 安装中的目录和egg文件直接复制到虚拟环境中。对于 Matplotlib,我还设法将二进制安装程序直接解压缩到 virtualenv 中(我只在 Python 3.2 的 Gohlke 安装程序中尝试过这个)。

I did manage in the past to easy_install NumPy into a virtualenv from a binary distribution, but I didn't manage this time (NumPy 1.5.1).

过去我确实设法将 NumPy 从二进制分发版轻松安装到 virtualenv 中,但这次我没有做到(NumPy 1.5.1)。

Someone recommended http://pypi.python.org/pypi/pygwhich should allow to install from binary packages to a virtualenv, but I haven't tried it yet.

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

回答by miguelfg

I didn't have to do the trick of unpacking the .exe file. I just activated my virtual environment, and then:

我不必解压 .exe 文件。我刚刚激活了我的虚拟环境,然后:

easy_install numpy