termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.15k stars 3.02k forks source link

[Bug]: Installtion of matplotlib fails #18640

Open tigran123 opened 10 months ago

tigran123 commented 10 months ago

Problem description

Trying to install matplotlib package fails. First it fails with the missing spawn.h header error, but after installing the libandroid-spawn package it fails in a different way.

            [402/402] ElideMiddle.ElideInTheMiddle
            failed
            make[2]: *** [CMakeFiles/build_ninja.dir/build.make:120: build_ninja-prefix/src/build_ninja-stamp/build_ninja-run_ninja_test_suite] Error 1
            make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/build_ninja.dir/all] Error 2
            make: *** [Makefile:136: all] Error 2
            Traceback (most recent call last):
              File "/data/data/com.termux/files/usr/tmp/pip-build-env-6hfir09o/overlay/lib/python3.11/site-packages/skbuild/setuptools_wrap.py", line 674, in s
etup
                cmkr.make(make_args, install_target=cmake_install_target, env=env)
              File "/data/data/com.termux/files/usr/tmp/pip-build-env-6hfir09o/overlay/lib/python3.11/site-packages/skbuild/cmaker.py", line 697, in make
                self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
              File "/data/data/com.termux/files/usr/tmp/pip-build-env-6hfir09o/overlay/lib/python3.11/site-packages/skbuild/cmaker.py", line 742, in make_impl
                raise SKBuildError(msg)

            An error occurred while building with CMake.
              Command:
                /data/data/com.termux/files/usr/bin/cmake --build . --target install --config Release --
              Install target:
                install
              Source directory:
                /data/data/com.termux/files/usr/tmp/pip-install-y0ci9y9f/ninja_e38cf2eba55f4061a1ce2c884d3d10b9
              Working directory:
                /data/data/com.termux/files/usr/tmp/pip-install-y0ci9y9f/ninja_e38cf2eba55f4061a1ce2c884d3d10b9/_skbuild/linux-aarch64-3.11/cmake-build
            Please check the install target is valid and see CMake's output for more information.

            [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
        ERROR: Failed building wheel for ninja
      Failed to build patchelf ninja
      ERROR: Could not build wheels for patchelf, ninja, which is required to install pyproject.toml-based projects
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install backend dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
dpkg: error processing package matplotlib (--configure):
 installed matplotlib package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 matplotlib
E: Sub-process /data/data/com.termux/files/usr/bin/dpkg returned an error code (1)

What steps will reproduce the bug?

pkg install matplotlib

What is the expected behavior?

it should succeed.

System information

termux-info:

Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=6845
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://packages-cf.termux.dev/apt/termux-main/ stable main
Updatable packages:
All packages up to date
termux-tools version:
1.39.5
Android version:
10
Kernel build information:
Linux localhost 4.9.118-23733710 #1 SMP PREEMPT Thu Jul 21 10:29:46 KST 2022 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-G965F
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.api versionCode:51
com.termux.styling versionCode:31
twaik commented 10 months ago

Post the whole log please.

tigran123 commented 10 months ago

typescript.txt

Here is the full typescript of pkg install matplotlib

romanovj commented 10 months ago

pkg i ninja patchelf

tigran123 commented 10 months ago

Thank you, that worked. But presumably those two packages should be listed as dependencies and installed automatically?

tigran123 commented 10 months ago

And now pip install gmpy fails with longinterp.h header missing...

romanovj commented 10 months ago

And now pip install gmpy fails with longinterp.h header missing...

gmpy 1.17 - release Jul 28, 2013

you can try your luck with 2.1.5 or switch to older python

pip install https://github.com/aleaxit/gmpy/archive/refs/tags/gmpy2-2.1.5.tar.gz

Suletta-Majo commented 10 months ago

My python programming environment has modules installed with pip in a virtual environment,
and I want to install matplotlib there as well. I was able to install it on Termux with pkg in the way described here,
but in the my activated virtual-env install matplotlib is failure
(env) [1.164s] [~/pyprog]$ pip install matplotlib
I can't install this with a wheel error If you have any ideas or suggestions, I would appreciate it

P.S. and information
Before coming here, I looked at the following topics and entered the command
https://github.com/termux/termux-app/discussions/3444
I don't understand what those commands mean :)
I'd like to post a log of the errors, but I'll upload the whole thing somewhere if necessary

(env) [1.164s][~/pyprog]$ pip install matplotlib Collecting matplotlib Using cached matplotlib-3.8.2.tar.gz (35.9 MB) Installing build dependencies ... error error: subprocess-exited-with-error × pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> [92 lines of output] .
.

By installing the same necessary modules as in the virtual environment on the pip on the raw termux environment side, which is not currently a virtual environment,
It can be used as an environment with matplotlib this is good, but the problem is not solved it

romanovj commented 10 months ago

@Suletta-Majo you can copy required modules from /data/data/com.termux/files/usr/lib/python3.11/site-packages to lib/python3.11/site-packages inside your venv

Suletta-Majo commented 10 months ago

@romanovj There were two directories, so I moved them with cp matplotlib*
has appeared in pip list in env! :) In the Python program for the graph image output test
The matplotlib module import error is gone, but I get a new numpy error
errormsg.txt

my testing code mplottes.py

import matplotlib.pyplot as plt

plt.plot([1, 2, 3])
plt.savefig('myfig.png')

On the raw termux side that is not a virtual environment, the graph creation was successful, and I was able to view the image with Chafa
Both are the same numpy version
I wonder if there are still things that aren't installed as dependencies? ☹️

romanovj commented 10 months ago

@Suletta-Majo patchelf --add-needed libpython3.11.so /data/data/com.termux/files/home/pyprog/env/lib/python3.11/site-packages/numpy/core/_multiarray_umath.cpython-311.so

Suletta-Majo commented 10 months ago

@romanovj thanks I tried it, but there error seems to be no change errormsg2.txt

romanovj commented 10 months ago

@Suletta-Majo try to execute inside venv, it will install all missing deps pip install matplotlib

you can also replace folders with numpy module inside venv with standart termux module

Suletta-Majo commented 10 months ago

@romanovj on my virtual-environment pip install matplotlib is run completed! but error is same

Let's run python and modules in a virtual environment on the site I learned because it was recommended and so I just followed it. I would like to move to programming in a direct environment that is easy and simple in terms of Termux😓 I'm not advanced user and As it is happening now, it is not like I can Corrections and countermeasures with it. thanks

romanovj commented 10 months ago

@Suletta-Majo did you replace numpy in venv with numpy from /data/data/com.termux/files/usr/lib/python3.11/site-packages ?

Suletta-Majo commented 10 months ago

@romanovj Because the machine translation displayed the copy source and destination as if it were reversed.
I didn't do it because I didn't understand the purpose of this work, but I understood it with a new statement and carried
it out Errors are now concise and short, and I feel like they can be solved
somehow Is this a good way to uninstall some duplicate matplotlib? (env) [165ms][~/pyprog]$ python3 mplottes.py /data/data/com.termux/files/home/pyprog/env/lib/python3.11/site-packages/matplotlib/projections/init.py:63: UserWarning: Unable to import Axes3D. This may be due to multiple versions of Matplotlib being installed (e.g. as a system package and as a pip package). As a result, the 3D projection is not available. warnings.warn("Unable to import Axes3D. This may be due to multiple versions of "

additional info below. my termux installed 3way matplotlib :/ not checked pip3 list rawandenvpip.txt

Suletta-Majo commented 10 months ago

success! thankyou @romanovj

i not copyed all required module
so when copy start. i found mystery module named mpl_toolkit
i copy this to venv module directory then plotprogram completed run and generate png graph successfully!
thx a lot and sorry my wrong action :D [76ms][/data/data/com.termux/files/usr/lib/python3.11/site-packages]$ cp -rf matplot ~/pyprog/env/lib/python3.11/site-packages [0.899s][/data/data/com.termux/files/usr/lib/python3.11/site-packages]$ cp -rf pypar ~/pyprog/env/lib/python3.11/site-packages [154ms][/data/data/com.termux/files/usr/lib/python3.11/site-packages]$ cp -rf count ~/pyprog/env/lib/python3.11/site-packages cp: cannot stat 'count': No such file or directory [115ms][1][/data/data/com.termux/files/usr/lib/python3.11/site-packages]$ cp -rf conto ~/pyprog/env/lib/python3.11/site-packages [135ms][/data/data/com.termux/files/usr/lib/python3.11/site-packages]$ cp -rf cycl ~/pyprog/env/lib/python3.11/site-packages [96ms][/data/data/com.termux/files/usr/lib/python3.11/site-packages]$ cp -rf kiwi* ~/pyprog/env/lib/python3.11/site-packages [154ms][/data/data/com.termux/files/usr/lib/python3.11/site-packages]$ cd mpl_toolkits /data/data/com.termux/files/usr/lib/python3.11/site-packages/mpl_toolkits . mplot3d axis myfig