2016-01-06 78 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的錯誤。