holographicSol / pdfDrive

Downloader + Module
5 stars 0 forks source link

error installing #2

Open johnredfield2099 opened 1 year ago

johnredfield2099 commented 1 year ago

how install pyqt5 in termux

~ $ pip install pyqt5
Collecting pyqt5 Using cached PyQt5-5.15.9.tar.gz (3.2 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error

× Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [25 lines of output] Traceback (most recent call last): File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in main() File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel whl_basename = backend.build_wheel(metadata_directory, config_settings) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/data/com.termux/files/usr/tmp/pip-build-env-tuw_e888/overlay/lib/python3.11/site-packages/sipbuild/api.py", line 46, in build_wheel project = AbstractProject.bootstrap('wheel', ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/data/com.termux/files/usr/tmp/pip-build-env-tuw_e888/overlay/lib/python3.11/site-packages/sipbuild/abstract_project.py", line 87, in bootstrap project.setup(pyproject, tool, tool_description) File "/data/data/com.termux/files/usr/tmp/pip-build-env-tuw_e888/overlay/lib/python3.11/site-packages/sipbuild/project.py", line 586, in setup self.apply_user_defaults(tool) File "/data/data/com.termux/files/usr/tmp/pip-install-if80m9wj/pyqt5_0e6370a00e2847da9573de2b4d8b773b/project.py", line 68, in apply_user_defaults super().apply_user_defaults(tool) File "/data/data/com.termux/files/usr/tmp/pip-build-env-tuw_e888/overlay/lib/python3.11/site-packages/pyqtbuild/project.py", line 70, in apply_user_defaults super().apply_user_defaults(tool) File "/data/data/com.termux/files/usr/tmp/pip-build-env-tuw_e888/overlay/lib/python3.11/site-packages/sipbuild/project.py", line 237, in apply_user_defaults self.builder.apply_user_defaults(tool) File "/data/data/com.termux/files/usr/tmp/pip-build-env-tuw_e888/overlay/lib/python3.11/site-packages/pyqtbuild/builder.py", line 69, in apply_user_defaults raise PyProjectOptionException('qmake', sipbuild.pyproject.PyProjectOptionException [end of output]

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

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details. ~ $

can you help me?

holographicSol commented 1 year ago

For termux the PyQt5 package will not need to be installed because pdfdrive.py will only import PyQt5 if the operating system is Windows. You may skip the pip installation of PyQt5 and that will be fine

holographicSol commented 1 year ago

Let me know how it goes!

holographicSol commented 1 year ago

Also I recommend running requirements.sh to make the required python module installations hands free, I have removed the PyQt5 pip install from the requirements.sh file in case any errors may be confusing for anyone running requirements.sh in termux, as the PyQt5 installation errors can safely be ignored because PyQt5 will not be imported if pdfdrive is running in termux.

holographicSol commented 1 year ago

Also, to run requirements.sh firstly inside the pdfDrive directory run:

chmod +x ./requirements.sh

Then you can execute with:

./requirements.sh

holographicSol commented 1 year ago

To add after testing a moment in Termux to see if I can be more helpful, if you encounter an error with aiofiles module like this for example:

~/pdfDrive $ python ./pdfdrive.py -k terminator Traceback (most recent call last): File "/data/data/com.termux/files/home/pdfDrive/./pdfdrive.py", line 15, in import aiofiles.os File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/aiofiles/os.py", line 31, in link = wrap(os.link) ^^^^^^^ AttributeError: module 'os' has no attribute 'link'. Did you mean: 'unlink'?

Then I patched aiofiles.os according to here: https://github.com/termux/termux-packages/commit/ce4e1b56c35988a51bcbdcf96acb1e6056066fca

Like this with these commands:

Take a look at aiofiles.os (according to your python version): cat /data/data/com.termux/files/usr/lib/python3.11/site-packages/aiofiles/os.py

Then open aiofiles.os in an editor, I like nano: nano /data/data/com.termux/files/usr/lib/python3.11/site-packages/aiofiles/os.py

Then if necessary patch the file to add the has attribute check for os.link, like this: """Async executor versions of file functions from the os module.""" import asyncio from functools import partial, wraps import os

def wrap(func): @wraps(func) async def run(*args, loop=None, executor=None, *kwargs): if loop is None: loop = asyncio.get_running_loop() pfunc = partial(func, args, **kwargs) return await loop.run_in_executor(executor, pfunc)

return run

from . import ospath as path

stat = wrap(os.stat) rename = wrap(os.rename) renames = wrap(os.renames) replace = wrap(os.replace) remove = wrap(os.remove) unlink = wrap(os.unlink) mkdir = wrap(os.mkdir) makedirs = wrap(os.makedirs) rmdir = wrap(os.rmdir) removedirs = wrap(os.removedirs)

if hasattr(os, "link"): link = wrap(os.link)

symlink = wrap(os.symlink) readlink = wrap(os.readlink) listdir = wrap(os.listdir) scandir = wrap(os.scandir) access = wrap(os.access)

if hasattr(os, "sendfile"): sendfile = wrap(os.sendfile)

Note the has attribute check added for os.link. Then after running the following command again:

python ./pdfdrive.py -k terminator

I get the following output:

~/pdfDrive $ python ./pdfdrive.py -k terminator

[ PDF Drive Downloader ]

[2023-04-30 03:17:54.468147] [Search] terminator [2023-04-30 03:17:54.468218] [Page] Page: 1 [2023-04-30 03:17:54.468274] [Scanning] https://www.pdfdrive.com/search?q=terminator&pagecount=&pubyear=&searchin=&page=1 [2023-04-30 03:17:54.468291] [Phase One] Gathering initial links... [2023-04-30 03:17:57.163642] [Domain Check] Domain checks passed. [2023-04-30 03:17:57.164056] [Results] 20 [2023-04-30 03:17:57.164198] [Phase One Time] 2.6959388009272516 [2023-04-30 03:17:57.164409] [Phase Two] Enumerating Links... [2023-04-30 03:18:07.940994] [Enumerated Results] 20 [2023-04-30 03:18:07.942098] [Phase Two Time] 10.7776774429949 [2023-04-30 03:18:07.943001] [Domain Check] Domain checks passed.


[2023-04-30 03:18:07.943454] [Progress] 1/20 (1/88) [2023-04-30 03:18:07.943676] [Category] terminator [2023-04-30 03:18:07.945968] [Book] learning-unix-for-os-x-going-deep-with-the-terminal-and-shell.pdf [2023-04-30 03:18:07.946200] [URL] https://www.pdfdrive.com//download.pdf?id=157992829&h=832e461858d230dea5657be3bcee2350&u=cache&ext=pdf [2023-04-30 03:18:19.058402] [Downloaded Successfully]


Hope this helps!