简体   繁体   中英

Python netifaces module windows installtion

I need to use the netifaces module for my project, and I could not manage to get it. I tried via easy_install, install the source code, but every time i get this message:

error: Unable to find vcvarsall.bat

I read in StackOverflow some answers about this error, but I couldent understand it...

There is any compiled version or an installer of netifaces? Thanks alot!

EDIT 1: After installing Visual Studio C++ I get this error..Any Help?

Searching for netifaces
Reading https://pypi.python.org/simple/netifaces/
Reading http://alastairs-place.net/netifaces
Reading http://alastairs-place.net/projects/netifaces
Best match: netifaces 0.8
Downloading http://alastairs-place.net/projects/netifaces/netifaces-0.8.tar.gz
Processing netifaces-0.8.tar.gz
Writing c:\users\daniel\appdata\local\temp\easy_install-gkcl9j\netifaces-0.8\setup.cfg
Running netifaces-0.8\setup.py -q bdist_egg --dist-dir c:\users\daniel\appdata\local\temp\easy_install-gkcl9j\netifaces-0.8\egg-dist-tmp-wuxsjm
netifaces.c
netifaces.c(406) : error C2275: 'PyObject' : illegal use of this type as an expression
        c:\python27\include\object.h(108) : see declaration of 'PyObject'
netifaces.c(406) : error C2065: 'py_family' : undeclared identifier
netifaces.c(407) : error C2275: 'PyObject' : illegal use of this type as an expression
        c:\python27\include\object.h(108) : see declaration of 'PyObject'
netifaces.c(407) : error C2065: 'list' : undeclared identifier
netifaces.c(407) : error C2065: 'py_family' : undeclared identifier
netifaces.c(407) : warning C4047: 'function' : 'PyObject *' differs in levels of indirection from 'int'
netifaces.c(407) : warning C4024: 'PyDict_GetItem' : different types for formal and actual parameter 2
netifaces.c(409) : error C2065: 'py_family' : undeclared identifier
netifaces.c(411) : error C2065: 'list' : undeclared identifier
netifaces.c(411) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
netifaces.c(411) : error C2065: 'list' : undeclared identifier
netifaces.c(411) : error C2065: 'list' : undeclared identifier
netifaces.c(411) : error C2065: 'list' : undeclared identifier
netifaces.c(415) : error C2065: 'list' : undeclared identifier
netifaces.c(416) : error C2065: 'list' : undeclared identifier
netifaces.c(416) : warning C4047: '=' : 'int' differs in levels of indirection from 'PyObject *'
netifaces.c(417) : error C2065: 'list' : undeclared identifier
netifaces.c(419) : error C2065: 'py_family' : undeclared identifier
netifaces.c(419) : error C2065: 'py_family' : undeclared identifier
netifaces.c(419) : error C2065: 'py_family' : undeclared identifier
netifaces.c(423) : error C2065: 'list' : undeclared identifier
netifaces.c(424) : error C2065: 'py_family' : undeclared identifier
netifaces.c(424) : warning C4047: 'function' : 'PyObject *' differs in levels of indirection from 'int'
netifaces.c(424) : warning C4024: 'PyDict_SetItem' : different types for formal and actual parameter 2
netifaces.c(424) : error C2065: 'list' : undeclared identifier
netifaces.c(424) : warning C4047: 'function' : 'PyObject *' differs in levels of indirection from 'int'
netifaces.c(424) : warning C4024: 'PyDict_SetItem' : different types for formal and actual parameter 3
netifaces.c(425) : error C2065: 'list' : undeclared identifier
netifaces.c(425) : error C2065: 'list' : undeclared identifier
netifaces.c(425) : error C2065: 'list' : undeclared identifier
netifaces.c(427) : error C2065: 'list' : undeclared identifier
netifaces.c(427) : warning C4047: 'function' : 'PyObject *' differs in levels of indirection from 'int'
netifaces.c(427) : warning C4024: 'PyList_Append' : different types for formal and actual parameter 1
netifaces.c(716) : error C2275: 'PyObject' : illegal use of this type as an expression
        c:\python27\include\object.h(108) : see declaration of 'PyObject'
netifaces.c(716) : error C2065: 'dict' : undeclared identifier
netifaces.c(718) : error C2065: 'dict' : undeclared identifier
netifaces.c(718) : warning C4047: '=' : 'int' differs in levels of indirection from 'PyObject *'
netifaces.c(720) : error C2065: 'dict' : undeclared identifier
netifaces.c(730) : error C2065: 'dict' : undeclared identifier
netifaces.c(730) : warning C4047: 'function' : 'PyObject *' differs in levels of indirection from 'int'
netifaces.c(730) : warning C4024: 'PyDict_SetItemString' : different types for formal and actual parameter 1
netifaces.c(732) : error C2065: 'dict' : undeclared identifier
netifaces.c(732) : warning C4047: 'function' : 'PyObject *' differs in levels of indirection from 'int'
netifaces.c(732) : warning C4024: 'PyDict_SetItemString' : different types for formal and actual parameter 1
netifaces.c(734) : error C2065: 'dict' : undeclared identifier
netifaces.c(734) : warning C4047: 'function' : 'PyObject *' differs in levels of indirection from 'int'
netifaces.c(734) : warning C4024: 'PyDict_SetItemString' : different types for formal and actual parameter 1
netifaces.c(740) : error C2065: 'dict' : undeclared identifier
netifaces.c(740) : warning C4047: 'function' : 'PyObject *' differs in levels of indirection from 'int'
netifaces.c(740) : warning C4024: 'add_to_family' : different types for formal and actual parameter 3
error: Setup script exited with error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2

Netifaces is written according to the c99 standard. In paricular the code is using intermingled declarations and code. Unfortunatly Microsofts compiler does not adhere to that standard and does not understand that mixing (when compiling *.c files). My solution was to simply rename the source file to 'netifaces.cpp'. That way the MS compiler does a C++ build where intermingling declarations and code is allowed. The renaming of that file also makes it necessary to edit 'setup.py' to change the file name there as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM