Python Forum
Where could I get _ctypes module except libffi-dev?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Where could I get _ctypes module except libffi-dev?
#1
I have an issue with Buildozer while trying to build Kivy program for Android, when I run buildozer android debug deploy run it says no module named _ctypes. On AskUbuntu I've seen the solution for people was installing libffi-dev - a system=wide package, not package of pip. But it seems there is no such package for some other Linux distributions (like Manjaro). So, where could I get _ctypes module?

Output:
.buildozer android debug deploy run [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: Unpacking sdl2_ttf for armeabi-v7a [INFO]: -> running basename https://www.libsdl.org...(and 48 more) [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/bootstrap_builds/sdl2-python3/jni [INFO]: sdl2_ttf is already unpacked, skipping [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: Unpacking sqlite3 for armeabi-v7a [INFO]: -> running basename https://www.sqlite.org...(and 37 more) [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/sqlite3/armeabi-v7a__ndk_target_21 [INFO]: sqlite3 is already unpacked, skipping [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: Unpacking python3 for armeabi-v7a [INFO]: -> running basename https://www.python.org...(and 34 more) [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3-libffi-openssl-sqlite3/armeabi-v7a__ndk_target_21 [INFO]: python3 is already unpacked, skipping [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: Unpacking sdl2 for armeabi-v7a [INFO]: -> running basename https://www.libsdl.org...(and 26 more) [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/bootstrap_builds/sdl2-python3/jni [INFO]: sdl2 is already unpacked, skipping [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: Unpacking setuptools for armeabi-v7a [INFO]: -> running basename https://pypi.python.o...(and 53 more) [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21 [INFO]: setuptools is already unpacked, skipping [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: Unpacking six for armeabi-v7a [INFO]: -> running basename https://pypi.python.or...(and 41 more) [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/six-python3/armeabi-v7a__ndk_target_21 [INFO]: six is already unpacked, skipping [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: Unpacking pyjnius for armeabi-v7a [INFO]: -> running basename https://github.com/kiv...(and 29 more) [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/pyjnius-python3-sdl2/armeabi-v7a__ndk_target_21 [INFO]: pyjnius is already unpacked, skipping [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: -> running rm -rf /home/Iam/KivyProjects...(and 127 more) [INFO]: -> running cp -a /home/Iam/KivyProjects/...(and 240 more) [INFO]: Unpacking kivy for armeabi-v7a [INFO]: -> running basename https://github.com/kiv...(and 25 more) [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/kivy-python3/armeabi-v7a__ndk_target_21 [INFO]: kivy is already unpacked, skipping [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: # Prebuilding recipes [INFO]: Prebuilding hostpython3 for armeabi-v7a [INFO]: hostpython3 has no prebuild_armeabi_v7a, skipping [INFO]: Prebuilding libffi for armeabi-v7a [INFO]: libffi has no prebuild_armeabi_v7a, skipping [INFO]: Applying patches for libffi[armeabi-v7a] [INFO]: libffi already patched, skipping [INFO]: Prebuilding openssl for armeabi-v7a [INFO]: openssl has no prebuild_armeabi_v7a, skipping [INFO]: Prebuilding sdl2_image for armeabi-v7a [INFO]: sdl2_image has no prebuild_armeabi_v7a, skipping [INFO]: Applying patches for sdl2_image[armeabi-v7a] [INFO]: sdl2_image already patched, skipping [INFO]: Prebuilding sdl2_mixer for armeabi-v7a [INFO]: sdl2_mixer has no prebuild_armeabi_v7a, skipping [INFO]: Applying patches for sdl2_mixer[armeabi-v7a] [INFO]: sdl2_mixer already patched, skipping [INFO]: Prebuilding sdl2_ttf for armeabi-v7a [INFO]: sdl2_ttf has no prebuild_armeabi_v7a, skipping [INFO]: Prebuilding sqlite3 for armeabi-v7a [INFO]: sqlite3 has no prebuild_armeabi_v7a, skipping [INFO]: Prebuilding python3 for armeabi-v7a [INFO]: python3 has no prebuild_armeabi_v7a, skipping [INFO]: Applying patches for python3[armeabi-v7a] [INFO]: python3 already patched, skipping [INFO]: Prebuilding sdl2 for armeabi-v7a [INFO]: sdl2 has no prebuild_armeabi_v7a, skipping [INFO]: Prebuilding setuptools for armeabi-v7a [INFO]: setuptools has no prebuild_armeabi_v7a, skipping [INFO]: Prebuilding six for armeabi-v7a [INFO]: six has no prebuild_armeabi_v7a, skipping [INFO]: Prebuilding pyjnius for armeabi-v7a [INFO]: pyjnius has no prebuild_armeabi_v7a, skipping [INFO]: Applying patches for pyjnius[armeabi-v7a] [INFO]: pyjnius already patched, skipping [INFO]: Prebuilding android for armeabi-v7a [INFO]: android has no prebuild_armeabi_v7a, skipping [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/android-python3-sdl2/armeabi-v7a__ndk_target_21/android [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: Prebuilding kivy for armeabi-v7a [INFO]: kivy has no prebuild_armeabi_v7a, skipping [INFO]: # Building recipes [INFO]: Building hostpython3 for armeabi-v7a [INFO]: hostpython3 said it is already built, skipping [INFO]: Building libffi for armeabi-v7a [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi [INFO]: -> running autogen.sh [INFO]: -> running autoreconf -vif [INFO]: -> running configure --host=arm-linux-and...(and 188 more) [INFO]: -> running make -j 2 libffi.la [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: -> running cp /home/Iam/KivyProjects/Tes...(and 241 more) [INFO]: Building openssl for armeabi-v7a [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/openssl/armeabi-v7a__ndk_target_21/openssl1.1 [INFO]: -> running perl Configure shared no-dso no...(and 37 more) [INFO]: Applying patch disable-sover.patch [INFO]: -> running patch -t -d /home/Iam/KivyPro...(and 259 more) [INFO]: -> running make build_libs [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: -> running cp /home/Iam/KivyProjects/Tes...(and 400 more) [INFO]: Building sdl2_image for armeabi-v7a [INFO]: Building sdl2_mixer for armeabi-v7a [INFO]: Building sdl2_ttf for armeabi-v7a [INFO]: Building sqlite3 for armeabi-v7a [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/sqlite3/armeabi-v7a__ndk_target_21/sqlite3 [INFO]: -> running ndk-build V=1 APP_PLATFORM=and...(and 27 more) [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: Building python3 for armeabi-v7a [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/python3-libffi-openssl-sqlite3/armeabi-v7a__ndk_target_21/python3/android-build [WARNING]: lld not found, linking without it. Consider installing lld if linker errors occur. [INFO]: Activating flags for sqlite3 [INFO]: Activating flags for libffi [INFO]: Activating flags for openssl [INFO]: Activating flags for android's zlib [INFO]: -> running configure --host=arm-linux-and...(and 366 more) [INFO]: -> running make all -j 2 INSTSONAME=libpython3.7m.so [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: Building sdl2 for armeabi-v7a [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/bootstrap_builds/sdl2-python3/jni [INFO]: -> running ndk-build V=1 [INFO]: <- directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/python-for-android [INFO]: Building setuptools for armeabi-v7a [INFO]: setuptools apparently isn't already in site-packages [INFO]: Installing setuptools into site-packages [INFO]: -> directory context /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools [INFO]: -> running python3 setup.py install -O2 -...(and 125 more) Exception in thread background thread for pid 18272: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib/python3.6/threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "/home/Iam/kivy_venv/lib/python3.6/site-packages/sh.py", line 1540, in wrap fn(*args, **kwargs) File "/home/Iam/kivy_venv/lib/python3.6/site-packages/sh.py", line 2459, in background_thread handle_exit_code(exit_code) File "/home/Iam/kivy_venv/lib/python3.6/site-packages/sh.py", line 2157, in fn return self.command.handle_command_exit_code(exit_code) File "/home/Iam/kivy_venv/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code raise exc sh.ErrorReturnCode_1: RAN: /home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py install -O2 --root=/home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myapp --install-lib=. STDOUT: Traceback (most recent call last): File "setup.py", line 11, in <module> import setuptools File "/home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/__init__.py", line 20, in <module> from setuptools.dist import Distribution, Feature File "/home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/dist.py", line 36, in <module> from setuptools import windows_support File "/home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/windows_support.py", line 2, in <module> import ctypes File "/home/Iam/KivyProjects/Test1/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/Lib/ctypes/__init__.py", line 7, in <module> from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes'
Reply
#2
https://github.com/python/cpython/blob/m.../_ctypes.c
Reply
#3
(Jan-10-2020, 03:29 AM)Larz60+ Wrote: https://github.com/python/cpython/blob/m.../_ctypes.c
Thanks. What to do? )
Reply
#4
Though may be I'll figure that out myself tomorrow, after getting some rest.
Reply
#5
Quote:Thanks. What to do? )
You asked where to find the file.
I provided that, but sorry to say that I don't use Kivy, so can't help on that end.
Check back, another moderator may pick up.
I did run into a similar problem some time back when trying to install wxpython on Linux mint. (was failing on _ctypes)
I'll go back and check my notes to see how I over came that and if it appears that my solution will fit your case, I'll report back.
I am running Linux Mint 19.1 Cinnamon, and it seems to be related.
Reply
#6
I found my notes for the wxpython install.
USE WITH EXTREME CAUTION
this may or may not help.
First, make sure the right version of python dev is installed. I was using 3.7 when I installed wxpython
second, replace wxpython with appropriate Kivy equivalent.
you will have to find a wheel for Kivy
but once I installed all of the packages (with the apt-get) it seemed to do the trick.
This mess took me several months to get right.
finally good luck.

Notes:
Output:
sudo apt-get install dpkg-dev sudo apt-get install build-essential sudo apt-get install python3.7-dev # update to appropriate Python version sudo apt-get install libwebkitgtk-dev sudo apt-get install libjpeg-dev sudo apt-get install libtiff-dev sudo apt-get install libgtk2.0-dev sudo apt-get install libsdl1.2-dev sudo apt-get install libgstreamer-plugins-base0.10-dev sudo apt-get install freeglut3 sudo apt-get install freeglut3-dev pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-16.04 wxPython see error messages: https://github.com/pyfa-org/Pyfa/issues/1421 * https://github.com/pyfa-org/Pyfa/issues/1468 https://github.com/pyfa-org/Pyfa/issues/1557 get wheel here: https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04/ make sure cp37 and 64 bit Example: https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04/wxPython-4.0.2-cp37-cp37m-linux_x86_64.whl
Reply
#7
I was able to get Kivy working. On Manjaro I made it without any libffi.
But strange that after I tried to uninstall some pip packages and reinstalled them again I got message no _ctypes.
Why that happens with Python? I have put back what was uninstalled, it should be the same.

1.I installed these system packages (with OS package manager): make gcc jdk8-openjdk zip python-pip.
2.Then python3.7 -m pip install --user --upgrade pip wheel setuptools virtualenv (reinstallation of which caused the problem).
3.Created a virtual environment and pip install kivy gave me no _ctypes.
Reply
#8
Thanks for sharing
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Ctypes and libffi.so.7 luxedo 1 5,983 Oct-23-2021, 09:24 PM
Last Post: DeaD_EyE
  ImportError: cannot import name 'Union' from '_ctypes' (unknown location) ciuffoly 15 10,264 Oct-09-2020, 06:58 AM
Last Post: ciuffoly

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020