简体   繁体   English

如何使用Python 2.7在Mac上安装ctypes

[英]How to install ctypes on Mac with Python 2.7

(.env) ➜  ~ easy_install ctypes
Searching for ctypes
Reading https://pypi.python.org/simple/ctypes/
No local packages or download links found for ctypes
error: Could not find suitable distribution for Requirement.parse('ctypes')


(.env) ➜  ~ pip install ctypes
Collecting ctypes
  Could not find a version that satisfies the requirement ctypes (from versions: )
No matching distribution found for ctypes

I use easy_install or pip to install ctypes,but they all failed. 我使用easy_install或pip来安装ctypes,但它们都失败了。

So I download ctypes-1.0.2-AMD64.zip to install 所以我下载ctypes-1.0.2-AMD64.zip进行安装

(.env) ➜  ctypes-1.0.2 sudo python setup.py build
Password:
running build
running build_py
running build_ext
Configuring static FFI library:
cd build/temp.macosx-10.11-intel-2.7/libffi && env CFLAGS='' '/Users/wyx/Downloads/ctypes-1.0.2/source/libffi/configure' 
env: /Users/wyx/Downloads/ctypes-1.0.2/source/libffi/configure: Permission denied
Failed

It failed again. 它又失败了。

(.env) ➜  ctypes-1.0.2 cd source/libffi
(.env) ➜  libffi ll
total 680
-rw-rw-rw-@  1 wyx  staff    1080 May 15  2007 LICENSE
-rw-rw-rw-@  1 wyx  staff   15851 May 15  2007 README
-rw-rw-rw-@  1 wyx  staff    3365 May 15  2007 aclocal.m4
-rw-rw-rw-@  1 wyx  staff   44911 May 15  2007 config.guess
-rw-rw-rw-@  1 wyx  staff   33113 May 15  2007 config.sub
-rw-rw-rw-@  1 wyx  staff  208082 May 15  2007 configure
-rw-rw-rw-@  1 wyx  staff    8716 May 15  2007 configure.ac
-rw-rw-rw-@  1 wyx  staff    4310 May 15  2007 fficonfig.h.in
-rw-rw-rw-@  1 wyx  staff    2125 May 15  2007 fficonfig.py.in
drwxr-xr-x@  4 wyx  staff     136 Apr  7 00:30 include
-rw-rw-rw-@  1 wyx  staff    7416 May 15  2007 install-sh
drwxr-xr-x@ 19 wyx  staff     646 Apr  7 00:30 src

Then I try change the permission of configure in 777 .But I fail again with a strange prompt. 然后我尝试在777中更改configure的权限。但是我再次以奇怪的提示失败。

(.env) ➜  ctypes-1.0.2 python setup.py build
running build
running build_py
running build_ext
Configuring static FFI library:
cd build/temp.macosx-10.11-intel-2.7/libffi && env CFLAGS='' '/Users/wyx/Downloads/ctypes-1.0.2/source/libffi/configure' 
env: /Users/wyx/Downloads/ctypes-1.0.2/source/libffi/configure: No such file or directory
Failed
(.env) ➜  ctypes-1.0.2 cd source/libffi
(.env) ➜  libffi ll
total 680
-rw-rw-rw-@  1 wyx  staff    1080 May 15  2007 LICENSE
-rw-rw-rw-@  1 wyx  staff   15851 May 15  2007 README
-rw-rw-rw-@  1 wyx  staff    3365 May 15  2007 aclocal.m4
-rw-rw-rw-@  1 wyx  staff   44911 May 15  2007 config.guess
-rw-rw-rw-@  1 wyx  staff   33113 May 15  2007 config.sub
-rwxrwxrwx@  1 wyx  staff  208082 May 15  2007 configure
-rw-rw-rw-@  1 wyx  staff    8716 May 15  2007 configure.ac
-rw-rw-rw-@  1 wyx  staff    4310 May 15  2007 fficonfig.h.in
-rw-rw-rw-@  1 wyx  staff    2125 May 15  2007 fficonfig.py.in
drwxr-xr-x@  4 wyx  staff     136 Apr  7 00:30 include
-rw-rw-rw-@  1 wyx  staff    7416 May 15  2007 install-sh
drwxr-xr-x@ 19 wyx  staff     646 Apr  7 00:30 src

Who can help me to solve it or Is there any other Python lib can instead of ctypes which can be installed more easier ? 谁可以帮助我解决它或者是否有任何其他Python库可以代替可以更容易安装ctypes

Since Python 2.5 ctypes is part of Python's standard library. 由于Python 2.5 ctypes是Python标准库的一部分。 Just import it: 只需导入它:

import ctypes

No need to install anything. 无需安装任何东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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