python - pip install 给出错误 : Unable to find vcvarsall. bat

标签 python python-2.7 pip zipline

在带有 Python 2.7 的 Windows 8 上使用 pip install zipline 会出现错误:

Downloading/unpacking six (from python-dateutil==2.1->delorean->zipline[all])
  Running setup.py egg_info for package six

Installing collected packages: blist, pytz, requests, python-dateutil, six
  Running setup.py install for blist
    building '_blist' extension
    error: Unable to find vcvarsall.bat
    Complete output from command C:\Python27\python.exe -c "import setuptools;__
file__='c:\\users\\ThatsMe\\appdata\\local\\temp\\pip-build-ThatsMe\\blist\\setup.py';ex
ec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" inst
all --record c:\users\ThatsMe\appdata\local\temp\pip-xvoky2-record\install-record.tx
t --single-version-externally-managed:

running install

running build

running build_py

running build_ext

building '_blist' extension

error: Unable to find vcvarsall.bat

问题:如何解决错误?运行 pip install zipline[all] 给出同样的错误...

最佳答案

这里的问题是 $python_install_prefix/Lib/distutils/msvc9compiler.py 中的第 292 行(此处使用 Python 3.4.3),它说:

VERSION = get_build_version()

这只会检查你的 python 所用的 MSVC 版本。只需将此行替换为您的实际 Visual Studio 版本,例如。 12.0 用于 MSVC2013

VERSION = 12.0

将解决问题。

更新:事实证明,这个版本被硬编码是有充分理由的。 MSVC C 运行时不需要在主要版本之间兼容。因此,当您使用不同的 VS 版本时,您可能会遇到运行时问题。所以我建议使用 VS 2008(Python 2.6 到 3.2)和 VS2010(Python 3.3 及更高版本),直到这个问题得到解决。

VS 2015 (see here) 和 Python 3.5 将提供二进制兼容性。

对于 Python 2.7 用户,Microsoft 发布了一个特殊的 Microsoft Visual C++ Compiler for Python 2.7无需安装整个VS 2008即可使用。

关于python - pip install 给出错误 : Unable to find vcvarsall. bat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19830942/

相关文章:

python - 上传图片 python tkinter

python - 从 Python URL 中提取特定文本

python - linux离线模式下的pip安装要求

python - Pandas 过滤器日期时间 : TypeError: can't compare offset-naive and offset-aware datetimes

python-2.7 - python : KenLM installation error

python - 失败到 'pip3 install apex' 导致构建密码失败(已安装)

python - 在 python 中使用模块

Python 使用 subprocess.Popen 关闭所有线程或进程

python - Mechanize python嵌套形式错误

python - 通过检查 int 范围替换文本