当我试图在我的Ubuntu系统上以桌面模式安装pgadmin4时,我收到了一个用于_ctypes的ModuleNotFoundError。
我做了一些研究,发现_ctypes需要安装libffi-dev包。然而,似乎libffi-dev和_ctypes是为Python2.7安装的,当我运行导入ctype时,它似乎可以工作:
$ 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添加到我的Python3.7配置中?
发布于 2019-11-05 17:57:05
如果你从源文件安装python,你必须像https://superuser.com/questions/1412975/how-to-build-and-install-python-3-7-x-from-source-on-debian-9-8中提到的那样手动安装一些必需的包。
实际上,由于没有找到libffi
,你应该在make
之后看到一些错误,如下面的截图所示。但是,尽管出现错误,您仍然可以运行make install
。当您在安装后打开python并导入模块时,它会给出这样的错误。
为了解决这个问题,您可以在安装./configure
、make
和make install
之前安装依赖包,即libffi
或libffi-devel
(redhat),如:Package libffi was not found in the pkg-config search path REDHAT6.5和https://bugs.python.org/issue31652中所述。
https://stackoverflow.com/questions/56810881
复制相似问题