5

When trying to install pgadmin4 in desktop mode on my Ubuntu system, I received a ModuleNotFoundError for _ctypes.

I did some research and found that _ctypes requires the libffi-dev package to be installed. However it seems that libffi-dev and thus _ctypes was installed for Python 2.7, when I run import ctypes it seems to work:

$ 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
>>> 

When I try to do the same for Python 3.7, it doesn't work:

$ 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'

How could I add the module _ctypes to my Python 3.7 configuration?

Kevin Vuong
  • 51
  • 1
  • 2
  • 4

1 Answers1

2

If you install python from source file, you have to install some required packages manually as mentioned in https://superuser.com/questions/1412975/how-to-build-and-install-python-3-7-x-from-source-on-debian-9-8.

Actually you are supposed to see some errors after make due to libffinot found as shown in the screenshot below. However, you can still run make install despite the error. When you open python after the installation and import the module, it then gives you such error.

To solve this problem, you can install the dependent package i.e libffi or libffi-devel(redhat) prior to ./configure, make and make install as mentioned in: Package libffi was not found in the pkg-config search path REDHAT6.5 and https://bugs.python.org/issue31652.

enter image description here