zhs
zhs

Reputation: 23

linux ModuleNotFoundError: No module named '_ctypes

[root@ONEVPS190105040754 ~]# youtube-dl -V
Traceback (most recent call last):
  File "/usr/local/python3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/python3/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/bin/youtube-dl/__main__.py", line 16, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 15, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/options.py", line 8, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/__init__.py", line 3, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/common.py", line 9, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/compat.py", line 7, in <module>
  File "/usr/local/python3/lib/python3.7/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
[root@ONEVPS190105040754 ~]# yum  install libffi-dev
Loaded plugins: changelog, fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.metrocast.net
 * extras: mirrors.maine.edu
 * updates: mirrors.advancedhosters.com
No package libffi-dev available.
Error: Nothing to do

I was going to use youtube-dl, but told me "ModuleNotFoundError: No module named '_ctypes'". I found some methods on the Internet, such as "yum install libffi-dev", but they still didn't work

Centos7

Upvotes: 0

Views: 28669

Answers (2)

fatestudio
fatestudio

Reputation: 91

This solved the same error for me on CentOS7:

yum install libffi-devel

Reference: issue31652

Upvotes: 8

Tyl
Tyl

Reputation: 5252

From this post :

It's a problem with your Python installation: it seems to be missing the _ctypes.so library. In this Debian system, it's /usr/lib/python2.6/lib-dynload/_ctypes.so. If you do have a lib-dynload directory, append it to the \$PYTHONPATH environment variable and see if it helps. (To test, open the interactive shell and try import _ctypes. To see the current path, use import sys and sys.path.)

Consider using the packaged version of Python if your operating system offers one.

(As a last resort, you can comment out the import ctypes line; it is only used with the --console-title option on Win32.)

Try above, see if it solve your problem.

Upvotes: 1

Related Questions