Python Pip 安装错误:无法找到 vcvarsall.bat。尝试了所有解决方案

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27670365/
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-08-19 02:06:07  来源:igfitidea点击:

Python Pip install Error: Unable to find vcvarsall.bat. Tried all solutions

pythonwindowsvisual-studiopython-2.7pip

提问by SantoshGupta7

I tried to install Scrapy for Python 2.7.8 (anaconda 2.1.0) 32-bit using

我尝试安装 Scrapy for Python 2.7.8 (anaconda 2.1.0) 32-bit 使用

pip install scrapy

And I got this error

我得到了这个错误

 error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat).

I have followed the solutions found in these stackover flow questions. Nothing worked.

我遵循了这些 stackover 流程​​问题中的解决方案。没有任何效果。

Microsoft Visual C++ Compiler for Python 2.7

适用于 Python 2.7 的 Microsoft Visual C++ 编译器

Can't find vcvarsall.bat file

找不到 vcvarsall.bat 文件

error: Unable to find vcvarsall.bat

错误:无法找到 vcvarsall.bat

Getting "error: Unable to find vcvarsall.bat" when running "pip install numpy" on windows7 64bit

在 windows7 64 位上运行“pip install numpy”时出现“错误:无法找到 vcvarsall.bat”

pip install gives error: Unable to find vcvarsall.bat

pip install 出现错误:无法找到 vcvarsall.bat

How do I point easy_install to vcvarsall.bat?

如何将 easy_install 指向 vcvarsall.bat?

pip install MySQL-python returns unable to find vcvarsall.bat

pip install MySQL-python 返回无法找到 vcvarsall.bat

This is the error, and a few lines above and below it:

这是错误,以及它上面和下面的几行:

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt
-> build\lib.win32-3.4\lxml\isoschematron\resources\xsl\iso-schematron-xslt1

running build_ext

building 'lxml.etree' extension

C:\Python34\lib\distutils\dist.py:260: UserWarning: Unknown distribution opt
ion: 'bugtrack_url'

  warnings.warn(msg)

error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat).


----------------------------------------
Command "C:\Python34\python.exe -c "import setuptools, tokenize;__file__='C:
\Users\San\AppData\Local\Temp\pip-build-wp6ei6r9\lxml\setup.py';exec(com
pile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __f
ile__, 'exec'))" install --record C:\Users\San\AppData\Local\Temp\pip-kfkzr_67-r
ecord\install-record.txt --single-version-externally-managed --compile" failed w
ith error code 1 in C:\Users\San\AppData\Local\Temp\pip-build-wp6ei6r9\lxml


I have both Microsoft Visual Studio 12.0, and Microsoft visual C++ compiler package for Python 2.7, both of which have the vcvarsall.bat file.

我有 Microsoft Visual Studio 12.0 和适用于 Python 2.7 的 Microsoft Visual C++ 编译器包,两者都有 vcvarsall.bat 文件。



I have a system variable that is called 'VS120COMNTOOLS' and is its path is set to

我有一个名为“VS120COMNTOOLS”的系统变量,其路径设置为

C:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\


I also added both paths to my environment variables. I've also tried just adding one, and then the other. My Path looks like this

我还将这两个路径都添加到我的环境变量中。我也试过只添加一个,然后添加另一个。我的路径看起来像这样

C:\Program Files\Java\jdk1.7.0_25\bin;\Python27;\Python2\python.exe;C:\Python27\Scripts\;C:\Users\San\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python.0\;C:\Program Files\Microsoft Visual Studio 12.0\VC\;


I also updated by my setup tools (I think to version 8), which should autodetect Microsoft Visual C++ Compiler for Python 2.7. However, I'm still getting the same error.

我还更新了我的设置工具(我认为是版本 8),它应该自动检测适用于 Python 2.7 的 Microsoft Visual C++ 编译器。但是,我仍然遇到相同的错误。



I have also tried using

我也试过使用

easy_install scrapy

And I get this error

我得到这个错误

error: Setup script exited with error: Microsoft Visual C++ 10.0 is required (Un

able to find vcvarsall.bat).

能够找到 vcvarsall.bat)。



I also have the following in my registry

我的注册表中还有以下内容

HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio.0\Setup\VC\ProductDir
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio.0\Setup\VC\ProductDir

采纳答案by Fatih1923

I have tried all suggestions and found my own simple solution.

我已经尝试了所有建议并找到了我自己的简单解决方案。

The problem is that codes written in external environment like Cneed compiler. Look for its own VS environment, i.e. VS 2008.

问题是在外部环境中编写的代码C需要编译器。寻找自己的VS环境,即VS 2008。

Currently my machine runs VS 2012 and faces Unable to find vcvarsall.bat. I studied codes that i want to install to find the VS version. It was VS 2008. i have add to system variable VS90COMNTOOLSas variable name and gave the value of VS120COMNTOOLS.

目前我的机器运行 VS 2012 并面对Unable to find vcvarsall.bat. 我研究了要安装的代码以找到 VS 版本。那是 VS 2008。我已将系统变量添加VS90COMNTOOLS为变量名并给出了VS120COMNTOOLS.

You can find my step by step solution below:

您可以在下面找到我的分步解决方案:

  1. Right click on My Computer.
  2. Click Properties
  3. Advanced system settings
  4. Environment variables
  5. Add New system variable
  6. Enter VS90COMNTOOLS to the variable name
  7. Enter the value of current version to the new variable.
  8. Close all windows
  1. 右键单击我的电脑。
  2. 单击属性
  3. 高级系统设置
  4. 环境变量
  5. 添加新的系统变量
  6. 在变量名中输入 VS90COMNTOOLS
  7. 将当前版本的值输入到新变量中。
  8. 关闭所有窗口

Now open a new session and pip install your-package

现在打开一个新会话并 pip install your-package

回答by avenet

Try installing this, it's a known workaround for enabling the C++ compiler for Python 2.7.

尝试安装,这是为 Python 2.7 启用 C++ 编译器的已知解决方法。

In my experience, when pip does not find vcvarsall.bat compiler, all I do is opening a Visual Studio console as it set the path variables to call vcvarsall.bat directly and then I run pip on this command line.

根据我的经验,当 pip 找不到 vcvarsall.bat 编译器时,我所做的就是打开 Visual Studio 控制台,因为它设置了路径变量以直接调用 vcvarsall.bat,然后我在此命令行上运行 pip。

回答by Hugues Fontenelle

Here too I can reproduce this problem with scrapyand psycopg2(both require C++ compiling), even though I have Microsoft Visual C++ Compiler for Python 2.7installed.

即使我安装了适用于 Python 2.7 的 Microsoft Visual C++ 编译器,我也可以使用scrapypsycopg2(都需要 C++ 编译)来重现这个问题。

It has to be noted that I use virtualenv. From your post I'm not sure whether you do the same.

必须指出的是,我使用virtualenv. 从您的帖子中,我不确定您是否也这样做。

Anyway I tried to skip the activation of the virtual environment. Then both scrapyand psycopg2installed fine.

无论如何,我试图跳过虚拟环境的激活。然后,两个scrapypsycopg2安装罚款。

My hypothesis: there is a conflict between this 2014 C++ compiler for Pythonand virtualenv. I do not know why nor how to solve it (and I'd be glad if someone can suggest a workaround).

我的假设:这个 2014 C++ 编译器的 Python和 virtualenv之间存在冲突。我不知道为什么也不知道如何解决它(如果有人可以提出解决方法,我会很高兴)。

回答by Broccoli Soup

I was getting the same error in python 3.4.3 too and I tried using the solutions mentioned here and elsewhere with no success.

我在 python 3.4.3 中也遇到了同样的错误,我尝试使用这里和其他地方提到的解决方案,但没有成功。

Microsoft makes a compiler available for Python 2.7 but it didn't do me much good since I am on 3.4.3.

Microsoft 为 Python 2.7 提供了一个编译器,但由于我使用的是 3.4.3,它对我没有多大好处。

Python since 3.3 has transitioned over to 2010 and you can download and install Visual C++ 2010 Express for free here: https://www.visualstudio.com/downloads/download-visual-studio-vs#d-2010-express

Python 从 3.3 过渡到 2010 年,您可以在此处免费下载和安装 Visual C++ 2010 Express:https: //www.visualstudio.com/downloads/download-visual-studio-vs#d-2010-express

Here is the official blog post talking about the transition to 2010 for 3.3: http://blog.python.org/2012/05/recent-windows-changes-in-python-33.html

以下是关于 3.3 过渡到 2010 年的官方博客文章:http: //blog.python.org/2012/05/recent-windows-changes-in-python-33.html

Because previous versions gave a different error for vcvarsall.bat I would double check the version you are using with "pip -V"

因为以前的版本为 vcvarsall.bat 给出了不同的错误,我会用“pip -V”仔细检查您使用的版本

C:\Users\B>pip -V
pip 6.0.8 from C:\Python34\lib\site-packages (python 3.4)

As a side note, I too tried using the latest version of VC++ (2013) first but it required installing 2010 express.

作为旁注,我也尝试首先使用最新版本的 VC++(2013),但它需要安装 2010 express。

From that point forward it should work for anyone using the 32 bit version, if you are on the 64 bit version you will then get the ValueError: ['path'] message because VC++ 2010 doesn't have a 64 bit compuler. For that you have to get the Microsoft SDK 7.1. I can't hyperlink the instruction for 64 bit because I am limited to 2 links per post but its at

从那时起,它应该适用于使用 32 位版本的任何人,如果您使用的是 64 位版本,那么您将收到 ValueError: ['path'] 消息,因为 VC++ 2010 没有 64 位编译器。为此,您必须获得 Microsoft SDK 7.1。我无法超链接 64 位指令,因为我每个帖子只能有 2 个链接,但它位于

Python PIP has issues with path for MS Visual Studio 2010 Express for 64-bit install on Windows 7

Python PIP 在 Windows 7 上用于 64 位安装的 MS Visual Studio 2010 Express 的路径有问题

回答by StatusQuo

After doing a lot of things, I upgraded pip, setuptoolsand virtualenv.

在做了很多事情之后,我升级了pip,setuptoolsvirtualenv.

  1. python -m pip install -U pip
  2. pip install -U setuptools
  3. pip install -U virtualenv
  1. python -m pip install -U pip
  2. pip install -U setuptools
  3. pip install -U virtualenv

I did steps 1, 2 in my virtual environment as well as globally. Next, I installed the package through pipand it worked.

我在我的虚拟环境以及全局环境中执行了步骤 1、2。接下来,我安装了该软件包pip并且它起作用了。