Closed connekitius closed 9 months ago
Python error log: grpcio.error.txt
error: "__ANDROID_API__ must be defined for Android builds."
error: "Requires Android API v21 and above"
try this
CFLAGS+=" -U__ANDROID_API__ -D__ANDROID_API__=28" pip install grpcio
I was experiencing the same issues installing grpcio on Android 8.0. The advice from @romanovj got me a bit further, but I still had problems with compilation steps further down the line, mostly with building third party libraries. The install command that finally ended up working for me was:
GRPC_PYTHON_DISABLE_LIBC_COMPATIBILITY=1 GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 GRPC_PYTHON_BUILD_SYSTEM_CARES=1 CFLAGS+=" -U__ANDROID_API__ -D__ANDROID_API__=26 -include unistd.h" LDFLAGS+=" -llog" pip install grpcio
Just make sure you have the headers for openssl, zlib, and c-ares in /data/data/com.termux/files/usr/include
.
I was experiencing the same issues installing grpcio on Android 8.0. The advice from @romanovj got me a bit further, but I still had problems with compilation steps further down the line, mostly with building third party libraries. The install command that finally ended up working for me was:
GRPC_PYTHON_DISABLE_LIBC_COMPATIBILITY=1 GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 GRPC_PYTHON_BUILD_SYSTEM_CARES=1 CFLAGS+=" -U__ANDROID_API__ -D__ANDROID_API__=26 -include unistd.h" LDFLAGS+=" -llog" pip install grpcio
Just make sure you have the headers for openssl, zlib, and c-ares in
/data/data/com.termux/files/usr/include
.
thanks for you termux lightnovel-crawler working
I was experiencing the same issues installing grpcio on Android 8.0. The advice from @romanovj got me a bit further, but I still had problems with compilation steps further down the line, mostly with building third party libraries. The install command that finally ended up working for me was:
GRPC_PYTHON_DISABLE_LIBC_COMPATIBILITY=1 GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 GRPC_PYTHON_BUILD_SYSTEM_CARES=1 CFLAGS+=" -U__ANDROID_API__ -D__ANDROID_API__=26 -include unistd.h" LDFLAGS+=" -llog" pip install grpcio
Just make sure you have the headers for openssl, zlib, and c-ares in
/data/data/com.termux/files/usr/include
.
Hi guys, I encountered similar problems, your solution does not apply to me. I post the description in #18444 , the following is a short snip of my output
aarch64-linux-android-clang -DNDEBUG -g -fwrapv -O3 -Wall -fstack-protector-strong -O3 -fstack-protector-strong -O3 -U__ANDROID_API__ -D__ANDROID_API__=28 -fPIC -I/data/data/com.termux/files/usr/include/python3.11 -c /data/data/com.termux/files/usr/tmp/tmplxfh016q/a.c -o None/data/data/com.termux/files/usr/tmp/tmplxfh016q/a.o
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/setuptools/_distutils/unixccompiler.py", line 185, in _compile
self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
File "/data/data/com.termux/files/usr/tmp/pip-install-t_dlesqn/grpcio_23481140d6e54aad8a262db7e50486d6/src/python/grpcio/_spawn_patch.py", line 58, in _commandfile_spawn
_classic_spawn(self, command, **kwargs)
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/setuptools/_distutils/ccompiler.py", line 1041, in spawn
spawn(cmd, dry_run=self.dry_run, **kwargs)
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/data/data/com.termux/files/usr/bin/aarch64-linux-android-clang' failed with exit code 1
Can you help a little bit with that? Thanks a lot
@noobyzy Based on your logs it looks like the installer is still trying to build c-ares
and failing. You mentioned that you tried several installation methods. What is the exact command you used that resulted in the log messages you posted here? Could you also post the result of running ls /data/data/com.termux/files/usr/include
?
@noobyzy Based on your logs it looks like the installer is still trying to build
c-ares
and failing. You mentioned that you tried several installation methods. What is the exact command you used that resulted in the log messages you posted here? Could you also post the result of runningls /data/data/com.termux/files/usr/include
?
@jtplatt99 Thanks.
The command that gives this output is
CFLAGS+=" -U__ANDROID_API__ -D__ANDROID_API__=28" pip install grpcio
Listing all the files and directories in the path, I have
FLAC byteswap.h dlfcn.h ffitarget.h gpg-error.h krb5.h libssh2_publickey.h lzma.h netinet pcrecpp.h riscv64-linux-android srt threads.h uninorm.h x264.h
FLAC++ bzlib.h drm fmt123.h gpgrt.h lame libssh2_sftp.h lzo netpacket pcrecpparg.h rmd160.h stdatomic.h tiff.h unistd.h x264_config.h
OMXAL c++ editline fnmatch.h graphite2 langinfo.h libswresample malloc.h nettle pcreposix.h sched.h stdint.h tiffconf.h unistdio.h x265.h
SLES cairo elf.h fontconfig grp.h lastlog.h libswscale math.h nghttp2 pixman-1 scsi stdio.h tiffio.h unistr.h x265_config.h
X11 camera endian.h form.h gssapi lcms2.h libv4l-plugin.h md2.h nl_types.h png.h search.h stdio_ext.h tiffio.hxx unistring x86_64-linux-android
aarch64-linux-android cap-ng.h err.h freetype2 gssapi.h lcms2_plugin.h libv4l1-videodev.h md4.h npth.h pngconf.h semaphore.h stdlib.h tiffvers.h unitypes.h xcb
aaudio clang errno.h fribidi gssrpc ldns libv4l1.h md5.h ocl_icd.h pnglibconf.h setjmp.h string.h time.h uniwbrk.h xen
absl clang-c error.h fts.h harfbuzz libavcodec libv4l2.h media ogg poll.h sha.h strings.h time64.h uniwidth.h xlocale.h
alloca.h clang-tidy eti.h ftw.h histedit.h libavdevice libv4l2rds.h memory.h openblas proc sha1.h svt-av1 tirpc utime.h xvid.h
amidi com_err.h evdns.h gawkapi.h i686-linux-android libavfilter libv4lconvert.h menu.h opencore-amrnb profile.h sha2.h syn123.h turbojpeg.h utmp.h xxh3.h
android complex.h event.h gcrypt.h iconv.h libavformat libxml2 misc opencore-amrwb pthread.h sha256.h sys uchar.h utmpx.h xxhash.h
aom cpio.h event2 gdbm.h idn2.h libavutil limits.h mntent.h opencv4 pty.h sha512.h syscall.h uconfig_local.h verto-module.h zconf.h
apt-pkg crypt.h evhttp.h getopt.h ifaddrs.h libbluray link.h mpf2mpfr.h openjpeg-2.5 pulse signal.h sysexits.h ucontext.h verto.h zdict.h
ar.h ctype.h evrpc.h gif_lib.h inttypes.h libcharset.h linux mpfr.h openssl pwd.h sndfile.h syslog.h udfread vid.stab zimg++.hpp
arm-linux-androideabi curl evutil.h gio-unix-2.0 jconfig.h libgen.h lld mpg123.h opus python3.11 sndfile.hh tar.h unbound-event.h video zimg.h
arpa curses.h execinfo.h glib-2.0 jerror.h libimagequant.h llvm mtd out123.h raqm-version.h sodium term.h unbound.h vo-amrwbenc zlib.h
asm-generic dav1d expat.h glob.h jmorecfg.h libintl.h llvm-c ncurses panel.h raqm.h sodium.h term_entry.h unctrl.h vorbis zmq.h
ass db.h expat_config.h gme jni.h libopenmpt localcharset.h ncurses.h paths.h rav1e sound termcap.h unicase.h vpx zmq_utils.h
assert.h db_185.h expat_external.h gmp.h jpeglib.h libpng16 locale.h ncurses_dll.h pcre.h rdma soxr-lsr.h termio.h uniconv.h wait.h zstd.h
assuan.h db_cxx.h fcntl.h gmpxx.h kadm5 libpostproc lz4.h ncursesw pcre2.h readline soxr.h termios.h unictype.h wchar.h zstd_errors.h
bash dbm.h features.h gnumake.h kdb.h libsmartcols lz4frame.h ndbm.h pcre2posix.h regex.h speex termux-api.h unigbrk.h wctype.h
bits dbus-1.0 fenv.h gnutls krad.h libssh lz4hc.h net pcre_scanner.h resolv.h sqlite3.h termux-auth.h unilbrk.h webp
brotli dirent.h ffi.h google krb5 libssh2.h lzma netdb.h pcre_stringpiece.h ripemd.h sqlite3ext.h theora uniname.h webrtc_audio_processing
I don't see c-ares
here. Is the problem with that? Do you know how to fix this?
Yes, if c-ares
was installed you would see the file ares.h
in that directory. You should be able to install that using:
pkg install c-ares
You'll also need to instruct pip to build using the system c-ares library instead of trying to built it on its own. To do that, try running the command I originally posted again and hopefully that should get you a bit further through the compilation.
GRPC_PYTHON_DISABLE_LIBC_COMPATIBILITY=1 GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 GRPC_PYTHON_BUILD_SYSTEM_CARES=1 CFLAGS+=" -U__ANDROID_API__ -D__ANDROID_API__=26 -include unistd.h" LDFLAGS+=" -llog" pip install grpcio
Since you're on Android 11 instead of 8 you might also want to change the -D__ANDROID_API__=26
to -D__ANDROID_API__=30
, but I'm not sure if that matters or not.
Thanks, your solution did work. I use
GRPC_PYTHON_DISABLE_LIBC_COMPATIBILITY=1 GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 GRPC_PYTHON_BUILD_SYSTEM_CARES=1 CFLAGS+=" -U__ANDROID_API__ -D__ANDROID_API__=30 -include unistd.h" LDFLAGS+=" -llog" pip install grpcio
My solution for installing PyPI
packages using pip
in a virtual environment in Termux
:
For example, to install the foo package that requires grpcio
:
pkg install python-grpcio
pip show grpcio # Check the path of "grpcio" in the system for later use
python3 -m venv venv
source venv/bin/activate
export PYTHONPATH="$PYTHONPATH:/data/data/com.termux/files/usr/lib/python3.11/site-packages"
pip install foo
but, we can use it with direnv
and make it easy to load the $PYTHONPATH
Problem description
gRPCio fails to build when installed via
pip install grpcio
or installed by any package who depends on grpcio. The last command before it fails is:What steps will reproduce the bug?
What is the expected behavior?
A successful installation
System information
termux-info:
Clang version: