【问题标题】:How to install ctypes on Mac with Python 2.7如何使用 Python 2.7 在 Mac 上安装 ctypes
【发布时间】:2016-04-06 16:49:51
【问题描述】:
(.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

我使用easy_install或pip安装ctypes,但都失败了。

于是我下载了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

又失败了。

(.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

然后我尝试在 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

谁能帮我解决这个问题,或者是否有任何其他 Python 库可以代替 ctypes 可以更轻松地安装

【问题讨论】:

  • ctypes 是一个标准模块,您不需要安装它。但我不使用 Mac,我使用 Linux。

标签: python macos python-2.7


【解决方案1】:

由于 Python 2.5 ctypes 是 Python 标准库的一部分。只需导入它:

import ctypes

无需安装任何东西。

【讨论】:

  • 谢谢,你解决了我的问题。我学习的课程使用 Python 2.4,在此之前我没有使用这个库。
猜你喜欢
  • 2016-10-27
  • 2015-04-02
  • 2018-06-26
  • 2013-04-21
  • 1970-01-01
  • 2012-06-14
  • 2018-03-15
  • 2011-06-07
  • 2011-10-19
相关资源
最近更新 更多