2016-01-06 60 views
1

我尝试安装ctypes的模块在Windows 7 python3.5和RHEL6.x python3.3但不与错误接受..7的ctypes/RHEL 6.x的python3.x

File "C:\Users\sawad\Downloads\ctypes-1.0.2\setup.py", line 24 
    raise Exception, "ctypes %s requires Python 2.3 or better" % __version__ 
       ^
SyntaxError: invalid syntax 

,当我使用Python 2.6.6版它提供了错误..

running install 
running build 
running build_py 
running build_ext 
building '_ctypes' extension 
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -fPIC -Ibuild/temp.linux-x86_64-2.6/libffi/include -Ibuild/temp.linux-x86_64-2.6/libffi -I/home/sawad/ctypes-1.0.2/source/libffi/src -I/usr/include/python2.6 -c source/_ctypes.c -o build/temp.linux-x86_64-2.6/source/_ctypes.o 
source/_ctypes.c:107:20: error: Python.h: No such file or directory 
source/_ctypes.c:108:26: error: structmember.h: No such file or directory 

...省略

source/_ctypes.c:4378: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Pointer_as_number’ 
source/_ctypes.c:4392: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Pointer_Type’ 
source/_ctypes.c:4537: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token 
source/_ctypes.c:4546: error: expected ‘)’ before ‘*’ token 
source/_ctypes.c:4570: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token 
source/_ctypes.c:4632: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘init_ctypes’ 
error: command 'gcc' failed with exit status 1 

我通常下载.tar.gz软件包,然后使用“python3 setup.py install”进行安装,因为我没有在我的服务器上直接访问互联网。那么这怎么能工作呢!

+0

你不需要安装ctypes;它是Python 2.5以后的标准库的一部分。 'ctypes' 1.0.2是古老的,不要使用它。 –

回答

1

根本不需要安装ctypes ;它是Python 2.5之后的Python标准库的一部分。请参阅module documentation

​​1.0.2是古老的,不要使用它。它是为Python 2.3和2.4编写的,并且从未调整为在Python 3上运行,这就是为什么你会得到语法错误。由于您缺少Python开发头文件(由python-devel RPM提供),您得到了Python 2的错误。