我试图在Windows 7 python3.5和RHEL6.x python3.3中安装 ctypes 模块但是不接受错误..
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”安装它,因为我的服务器没有直接的Internet访问权限。那怎么能起作用呢?
答案 0 :(得分:1)
您根本不需要安装ctypes ;它是Python标准库的一部分,从Python 2.5开始。请参阅module documentation。
ctypes
1.0.2是古老的,不要使用它。它是为Python 2.3和2.4编写的,从未调整为在Python 3上运行,这就是为什么你会得到语法错误。您在Python 2中遇到了错误,因为您缺少Python开发标头(由python-devel
RPM提供)。