本文介绍了无法建立网络脸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 Windows 构建 python netifaces.我正在使用 microsoft visual c++ express 2010 版.当我运行命令 python setup.py install 时,我得到以下日志和错误:

I am trying to build python netifaces for windows. I am using microsoft visual c++ express 2010 edition. When I run the command python setup.py install I get the following log and errors:

running install
running bdist_egg
running egg_info
writing netifaces.egg-info\PKG-INFO
writing top-level names to netifaces.egg-info\top_level.txt
writing dependency_links to netifaces.egg-info\dependency_links.txt
reading manifest file 'netifaces.egg-info\SOURCES.txt'
writing manifest file 'netifaces.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_ext
building 'netifaces' extension
c:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox /MD /
W3 /GS- /DNDEBUG -DWIN32=1 -DNETIFACES_VERSION=0.8 -Ic:\python27\include -Ic:\py
thon27\PC /Tcnetifaces.c /Fobuild\temp.win32-2.7\Release\netifaces.obj
netifaces.c
netifaces.c(410) : error C2275: 'PyObject' : illegal use of this type as an expr
ession
        c:\python27\include\object.h(108) : see declaration of 'PyObject'
netifaces.c(411) : error C2275: 'PyObject' : illegal use of this type as an expr
ession
        c:\python27\include\object.h(108) : see declaration of 'PyObject'
netifaces.c(720) : error C2275: 'PyObject' : illegal use of this type as an expr
ession
        c:\python27\include\object.h(108) : see declaration of 'PyObject'
netifaces.c(720) : error C2065: 'dict' : undeclared identifier
netifaces.c(722) : error C2065: 'dict' : undeclared identifier
netifaces.c(722) : warning C4047: '=' : 'int' differs in levels of indirection f
rom 'PyObject *'
netifaces.c(724) : error C2065: 'dict' : undeclared identifier
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 f
ormal and actual parameter 1
netifaces.c(736) : error C2065: 'dict' : undeclared identifier
netifaces.c(736) : warning C4047: 'function' : 'PyObject *' differs in levels of
 indirection from 'int'
netifaces.c(736) : warning C4024: 'PyDict_SetItemString' : different types for f
ormal and actual parameter 1
netifaces.c(738) : error C2065: 'dict' : undeclared identifier
netifaces.c(738) : warning C4047: 'function' : 'PyObject *' differs in levels of
 indirection from 'int'
netifaces.c(738) : warning C4024: 'PyDict_SetItemString' : different types for f
ormal and actual parameter 1
netifaces.c(744) : error C2065: 'dict' : undeclared identifier
netifaces.c(744) : warning C4047: 'function' : 'PyObject *' differs in levels of
 indirection from 'int'
netifaces.c(744) : warning C4024: 'add_to_family' : different types for formal a
nd actual parameter 3
error: command '"c:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe"' f
ailed with exit status 2

抱歉格式不正确我错过了什么?

sorry for the bad formattingWhat am I missing?

推荐答案

将 netifaces.c 重命名为 netifaces.cpp(并相应地更新 setup.py).

Rename netifaces.c to netifaces.cpp (and update the setup.py accordingly).

原因是.c扩展名,MSVC将这些文件解释为遵循C89,netifaces.c没有遵循;更多信息在这里:错误 C2275:非法使用此类型作为表达式

The reason is that with .c extensions, MSVC interprets these files as adhering to C89, which netifaces.c does not follow; more info here:error C2275 : illegal use of this type as an expression

这篇关于无法建立网络脸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 09:58