4

当尝试在我的 Ubuntu 系统上以桌面模式安装 pgadmin4 时,我收到了 _ctypes 的 ModuleNotFoundError。

我做了一些研究,发现 _ctypes 需要安装 libffi-dev 包。但是,似乎为 Python 2.7 安装了 libffi-dev 并因此安装了 _ctypes,当我运行 import ctypes 时,它似乎可以工作:

$ python2
Python 2.7.15+ (default, Nov 27 2018, 23:36:35) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> 

当我尝试对 Python 3.7 执行相同操作时,它不起作用:

$ python
Python 3.7.3 (default, Jun 21 2019, 12:46:58) 
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'

如何将模块 _ctypes 添加到我的 Python 3.7 配置中?

4

1 回答 1

2

如果从源文件安装 python,则必须手动安装一些必需的包,如https://superuser.com/questions/1412975/how-to-build-and-install-python-3-7-x-from中所述-source-on-debian-9-8

make实际上,由于未找到,您应该会看到一些错误,libffi如下面的屏幕截图所示。make install但是,尽管出现错误,您仍然可以运行。当您在安装后打开 python 并导入模块时,它会给您这样的错误。

要解决这个问题,可以在之前安装依赖包ielibffi或者libffi-devel(redhat) ./configure,如: Package libffi was not found in the pkg-config search path REDHAT6.5 and https://bugs.python.org/问题31652makemake install

在此处输入图像描述

于 2019-11-05T09:57:05.017 回答