When using C to write extensions to python3, we encountered the following problems:
Write * module. C and setup. Py files and execute them
python setup.py build
Unable to find vcfarsall.bat
I have VS2005 and VC6 on my machine, but I still report an error
Search a lot of information:
Online solutions are as follows:
Download MinGW environment and add environment variables
Use
python setup.py build –compiler=mingw32
I feel that this method just bypasses this problem, but it is not really a solution. Moreover, in my system, Python is compiled with VS, but the extension module is compiled with MinGW GCC. I feel that there may be a problem
But there is no detailed explanation on the Internet
After carefully reading the. Py file in the C/Python 32/lib/distutils directory, it is found that the sentence “unable to find vcvar sall. Bat” is in msvc9compiler. Py
Further study of this document reveals the problem
It looks for the vs directory in the registry, and then looks for vcvarsall.bat in the vs directory
But the problem is that in python32, the default is vc9.0, which is VS2008, so it can’t find the key value in the registry and returns none
productdir = Reg.get_ value(r”%s/Setup/VC” % vsbase,
“productdir”)
The value of vsbase is: software/Microsoft/Visual Studio/9.0
The specific modification code is as follows:
In msvc9compiler.py
def find_ Vcvarsall (version) is used to find vcvarsall. Bat version, which is the version number, is actually 9.0
vc_ env = query_ vcvarsall(VERSION, plat_ spec)
VERSION = get_ build_ Version () because python32 itself is built by vc9.0, version is 9.0
Modify the msvccompiler function:
vc_env = query_vcvarsall(VERSION, plat_spec)
For:
vc_env = query_vcvarsall(8.0, plat_spec)
But there is another sentence:
if VERSION < 8.0:
raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION)
It seems that distutils in Python 3.2 only supports compilers above VC8.0, that is, compilers above VS2005
Similar Posts:
- Python error: Unable to find vcvarsall.bat [How to Solve]
- Solving an error: unable to find vcfarsall.bat experience
- Python Visual C++ 9.0 is required [Two Method to Solve]
- PyCrypto Install error: Unable to find vcvarsall.bat
- CMake: How to Complie Log4cplus
- Ubuntu18.04 (Python3.9) Error: ImportError: Cannot import name ‘sysconfig’ from ‘distutils’
- Go to: install C extended compiler environment of Python under windows (solve the problem of “unable to find vcfarsall. Bat”
- [Solved] cc1plus.exe: out of memory allocating bytes
- codeblocks17.12 debug :ERROR: You need to specify a debugger program in the debuggers’s set…
- Installing mingw64 and msys2 in win10