Skip to main content

How to fix "ValueError when trying to compile python module with VC Express"

When I tried to compile the python, I always get compile issue as following:
  File "C:\Python26\lib\distutils\", line 358, in 
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Python26\lib\distutils\", line 274, in 
    raise ValueError(str(list(result.keys())))
ValueError: [u'path']
Python community discussed a lot but no solution:

The root cause is because the latest visual studio change the *.bat file a lot especially on 64bit env. The python 2.7 didn't update the path accordingly. 
Based on the assumption above, the following solution worked for me.
To install Visual Studio 2008 Express Edition with all required components:
1. Install Microsoft Visual Studio 2008 Express Edition. The main Visual Studio 2008 Express installer is available from (the C++ installer name is vcsetup.exe):
This package can be installed using the default options.
2. Install the Microsoft Windows SDK. The Microsoft Windows SDK is available by searching Microsoft's download site, or by going directly to:
Download the Windows Server 2008 & .NET 3.5 SDK. Do not install beta or 'Release Candidate' (RC) versions. Also do NOT install "Microsoft Windows SDK for Windows 7 and .NET Framework 4" (version 7.1); if you want to use a 7.x version choose the "Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1".
2.1. While installing the SDK, you must select "x64 Compilers and Tools". For example, in the SDK installer above:
On the screen "Installation Options"
Select "Developer Tools"->"Visual C++ Compilers".
This item has the Feature Description "Install the Visual C++ 9.0 Compilers. These compilers allow you to target x86, x64, IA64 processor architectures."
3. To verify that you have all installed components, check that the Microsoft SDK contains the "amd64" version of the C/C++ compiler "cl.exe". This is usually installed into
 C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\cl.exe
4. copy .../VC/bin/vcvars64.bat to .../VC/bin/vcvarsamd64.bat
5. copy .../VC/bin/vcvars64.bat to .../VC/bin/amd64/vcvarsamd64.bat

Now, get the coffee and wait for the compile result:)


  1. Hey there, I am having the same issue, but I have Visual Studio 2010 and .NET 4 SDK installed on my computer. I just did not quite understand why I had to install 2008 version and SDK 3.5?

    1. the latest 2010 removed some bat files which are required to compile python module.

  2. fantastic post.. it works for me !

  3. In the last two steps:
    4. copy .../VC/bin/vcvars64.bat to .../VC/bin/vcvarsamd64.bat

    5. copy .../VC/bin/vcvars64.bat to .../VC/bin/amd64/vcvarsamd64.bat

    are we supposed to copy the file vcvars64.bat to folder amd64 and rename it as vcvarsamd64.bat?

  4. This comment has been removed by the author.

  5. First of all thanks for putting up these helpful instructions.

    I am using a windows 8.1, python 3.4 amd64 bit computer with visual C++ express 2008 and 10 installed on the system.

    I followed your instructions but I am still getting the ValueError when trying to install my module. should we also have vcvars64.bat file in the amd64 folder as well.

    And for the 2.1 Step I do not see the installation options you speak of.

    1. I feel painful that we can't see the installation options for 2.1 step. are u using 32 bit pc or 64 bits?

    2. Got the same problem
      I use 64 bit and tried everything nothing seems to working. I use vs 2013 and python 3.4 (I want to use mmh3). get still a path error because there is no such a path \Bin\SetEnv.cmd in "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd under windows 8 :/

  6. This comment has been removed by the author.

  7. You saved my life !!! ...thanks

  8. I have just one thing to say you: Thank you so much! :D

  9. I've searched far and wide for an answer to this problem, and this was the one. You are a god among mere mortals.

  10. Hiện nay, nhiều nhà doanh nghiệp đang phải tốn rất nhiều chi phí khi nhập khẩu hàng hóa từ nhật bản vì các thủ tục hải quan. Tuy nhiên, khi dịch vụ của chúng tôi ra đời đã có thể giải quyết được những vấn đề khó khăn này. Chúng tôi nhận mua hộ hàng nhật tại các trang web nổi tiếng của Nhật Bảm mua hàng trên web nhật. Hơn nữa, chúng tôi còn phát triển mạnh dịch vụ chuyển đồ từ nhật về việt nam. Chuyển hàng ở các tỉnh thành lớn như hà nội, hồ chí minh, đã nẵng mới mức phi cực rẻ. nhận chuyển hàng từ nhật về hà nội hoặc nhận chuyển hàng từ nhật về tphcm . Quý khách chỉ cần order hàng từ nhật về việt nam và sử dụng dịch vụ order hàng nhật để nhận được những sự hài lòng nhất từ dịch vụ của chúng tôi.

    Ngoài ra, chúng tôi còn cung cấp thêm dịch vụ mua hàng trên amazon ship về việt nam, quý khách hàng có thể mua sắm tưng bừng tại hệ thông amazon

    Please refer this site to download binary compile libraries for any python module and after downloading .whl file install like
    pip -m install

  12. Zheng! You are the man!!! This is pure gold!

    Thank you for having the patience to figure this out, and the compassion to write it up so clearly for the rest of us!!!

  13. Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!
    Commercial Audio Visual Design & Commercial AV System integration & Commercial AV installation Southbay

  14. This comment has been removed by the author.

  15. Even after following the above procedure,I am getting the following errors.Please help if possible.
    cl : Command line error D8021 : invalid numeric argument '/Wno-cpp'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2


Post a Comment

Popular posts from this blog

How to convert the ResultSet to Stream

Java 8 provided the Stream family and easy operation of it. The way of pipeline usage made the code clear and smart. However, ResultSet is still go with very legacy way to process. Per actual ResultSet usage, it is really helpful if converted as Stream. Here is the simple usage of above: StreamUtils.uncheckedConsumer is required to convert the the SQLException to runtimeException to make the Lamda clear.

My Practices to fix Applet stuck/frozen/crash Issues

Practice 1: Follow the Applet Life Cycle. As we all knew, all Java instances have the life cycles, the same to Applet. Applet contains the following major events per h ttp:// : It can  initialize  itself.  --  public void init()  It can  start  running.   --  public void start() It can  stop  running.   -- public void stop() It can perform a  final cleanup , in preparation for being unloaded. -- public void destroy() in real coding practice, I usually override start() and make JS callback to tell browser, the applet is ready to call.  If the JS try to call applet before the applet is ready, it will cause some JVM crash issue on browser especially on chrome PC or any browser on MAC (MAC hates java, I guess).     Practice 2: Use  AccessController.doPrivileged to access local resources As responded to jvm security issue, oracle put more and more  security constrains to access local resources although the ap