Dineshkarthik / telegram_media_downloader

Download media files from a telegram conversation/chat/channel up to 2GiB per file
MIT License
2.16k stars 364 forks source link

PyYAML and _sqlite3 issue #496

Open caio-passos opened 4 months ago

caio-passos commented 4 months ago

When installing with Python 3.12, if PyYAML == 6.0 it wont install:


Using cached PyYAML-6.0.tar.gz (124 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [54 lines of output]
      running egg_info
      writing lib/PyYAML.egg-info/PKG-INFO
      writing dependency_links to lib/PyYAML.egg-info/dependency_links.txt
      writing top-level names to lib/PyYAML.egg-info/top_level.txt
      Traceback (most recent call last):
        File "/home/ludo/.local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/ludo/.local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/ludo/.local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
          exec(code, locals())
        File "<string>", line 288, in <module>
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 184, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
          dist.run_commands()
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 970, in run_commands
          self.run_command(cmd)
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 974, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
          cmd_obj.run()
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 321, in run
          self.find_sources()
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 329, in find_sources
          mm.run()
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 550, in run
          self.add_defaults()
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py", line 588, in add_defaults
          sdist.add_defaults(self)
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/command/sdist.py", line 102, in add_defaults
          super().add_defaults()
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/sdist.py", line 250, in add_defaults
          self._add_defaults_ext()
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/sdist.py", line 335, in _add_defaults_ext
          self.filelist.extend(build_ext.get_source_files())
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<string>", line 204, in get_source_files
        File "/tmp/pip-build-env-4cvr3aaq/overlay/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
          raise AttributeError(attr)
      AttributeError: cython_sources
      [end of output]

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

× Getting requirements to build wheel 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.
make: *** [Makefile:7: install] Error 1

if you do change to: PyYAML > 6.0 it is able to "make install", but however it is still not able to properly run.

With PopOS 22.04, Python 3.12 and PyYAML > 6.0, after installing, this happens when the script runs:

Traceback (most recent call last):
  File "/home/ludo/telegram_media_downloader/media_downloader.py", line 7, in <module>
    import pyrogram
  File "/home/ludo/.local/lib/python3.12/site-packages/pyrogram/__init__.py", line 39, in <module>
    from .client import Client
  File "/home/ludo/.local/lib/python3.12/site-packages/pyrogram/client.py", line 52, in <module>
    from pyrogram.storage import FileStorage, MemoryStorage
  File "/home/ludo/.local/lib/python3.12/site-packages/pyrogram/storage/__init__.py", line 19, in <module>
    from .file_storage import FileStorage
  File "/home/ludo/.local/lib/python3.12/site-packages/pyrogram/storage/file_storage.py", line 21, in <module>
    import sqlite3
  File "/usr/local/lib/python3.12/sqlite3/__init__.py", line 57, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/local/lib/python3.12/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'

My current config:

last_read_message_id: 0 ids_to_retry: [] media_types:

Python Version Python: 3.12

OS: PopOS 22.04

Sebalux commented 3 months ago

For me, changing from PyYAML == 6.0 to PyYAML > 6.0 helped running the pip requirements build.

luistombo commented 1 month ago

I had the same issue when upgrading from Ubuntu 22 to Ubuntu 24. Changing the requirement to PyYAML>6.0 as suggested below I tried to do the same fot TgCrypto and Rich, allowing the build to use the newer versions but to no avail. This is where the make fails:

python3 -m pip install --upgrade pip setuptools
Requirement already satisfied: pip in /home/luis/telegram/tmd/lib/python3.12/site-packages (24.2)
Requirement already satisfied: setuptools in /home/luis/telegram/tmd/lib/python3.12/site-packages (75.1.0)
python3 -m pip install -r requirements.txt
Collecting https://github.com/Dineshkarthik/pyrogram/archive/refs/heads/master.zip (from -r requirements.txt (line 1))
  Using cached https://github.com/Dineshkarthik/pyrogram/archive/refs/heads/master.zip
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting PyYAML>6.0 (from -r requirements.txt (line 2))
  Using cached PyYAML-6.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
Collecting rich>12.5.1 (from -r requirements.txt (line 3))
  Downloading rich-13.9.1-py3-none-any.whl.metadata (18 kB)
Collecting TgCrypto>1.2.3 (from -r requirements.txt (line 4))
  Using cached TgCrypto-1.2.5.tar.gz (37 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting pyaes==1.6.1 (from Pyrogram==2.0.106->-r requirements.txt (line 1))
  Using cached pyaes-1.6.1-py3-none-any.whl
Collecting pysocks==1.7.1 (from Pyrogram==2.0.106->-r requirements.txt (line 1))
  Using cached PySocks-1.7.1-py3-none-any.whl.metadata (13 kB)
Collecting markdown-it-py>=2.2.0 (from rich>12.5.1->-r requirements.txt (line 3))
  Downloading markdown_it_py-3.0.0-py3-none-any.whl.metadata (6.9 kB)
Collecting pygments<3.0.0,>=2.13.0 (from rich>12.5.1->-r requirements.txt (line 3))
  Using cached pygments-2.18.0-py3-none-any.whl.metadata (2.5 kB)
Collecting mdurl~=0.1 (from markdown-it-py>=2.2.0->rich>12.5.1->-r requirements.txt (line 3))
  Downloading mdurl-0.1.2-py3-none-any.whl.metadata (1.6 kB)
Using cached PySocks-1.7.1-py3-none-any.whl (16 kB)
Using cached PyYAML-6.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (767 kB)
Downloading rich-13.9.1-py3-none-any.whl (242 kB)
Downloading markdown_it_py-3.0.0-py3-none-any.whl (87 kB)
Using cached pygments-2.18.0-py3-none-any.whl (1.2 MB)
Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Building wheels for collected packages: Pyrogram, TgCrypto
  Building wheel for Pyrogram (pyproject.toml) ... done
  Created wheel for Pyrogram: filename=Pyrogram-2.0.106-py3-none-any.whl size=3573814 sha256=bf2fbccc77604a8b599d2efab1a947ddd1a414939990930cd1e295aa7cf93107
  Stored in directory: /tmp/pip-ephem-wheel-cache-7dx07wp5/wheels/1f/c7/e8/8ff2c993a059b74ef7ef7ddfcd9226cf4e07be175362a91d33
  Building wheel for TgCrypto (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for TgCrypto (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      /tmp/pip-build-env-hpyvfa86/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'test_suite'
        warnings.warn(msg)
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-312/tests
      copying tests/__init__.py -> build/lib.linux-x86_64-cpython-312/tests
      creating build/lib.linux-x86_64-cpython-312/tests/ctr
      copying tests/ctr/test_ctr.py -> build/lib.linux-x86_64-cpython-312/tests/ctr
      copying tests/ctr/__init__.py -> build/lib.linux-x86_64-cpython-312/tests/ctr
      creating build/lib.linux-x86_64-cpython-312/tests/ige
      copying tests/ige/test_ige.py -> build/lib.linux-x86_64-cpython-312/tests/ige
      copying tests/ige/__init__.py -> build/lib.linux-x86_64-cpython-312/tests/ige
      creating build/lib.linux-x86_64-cpython-312/tests/cbc
      copying tests/cbc/test_cbc.py -> build/lib.linux-x86_64-cpython-312/tests/cbc
      copying tests/cbc/__init__.py -> build/lib.linux-x86_64-cpython-312/tests/cbc
      running build_ext
      building 'tgcrypto' extension
      creating build/temp.linux-x86_64-cpython-312/tgcrypto
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -I/home/luis/telegram/tmd/include -I/usr/include/python3.12 -c tgcrypto/aes256.c -o build/temp.linux-x86_64-cpython-312/tgcrypto/aes256.o
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -I/home/luis/telegram/tmd/include -I/usr/include/python3.12 -c tgcrypto/cbc256.c -o build/temp.linux-x86_64-cpython-312/tgcrypto/cbc256.o
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -I/home/luis/telegram/tmd/include -I/usr/include/python3.12 -c tgcrypto/ctr256.c -o build/temp.linux-x86_64-cpython-312/tgcrypto/ctr256.o
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -I/home/luis/telegram/tmd/include -I/usr/include/python3.12 -c tgcrypto/ige256.c -o build/temp.linux-x86_64-cpython-312/tgcrypto/ige256.o
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -I/home/luis/telegram/tmd/include -I/usr/include/python3.12 -c tgcrypto/tgcrypto.c -o build/temp.linux-x86_64-cpython-312/tgcrypto/tgcrypto.o
      tgcrypto/tgcrypto.c:23:10: fatal error: Python.h: No existe el archivo o el directorio
         23 | #include <Python.h>
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for TgCrypto
Successfully built Pyrogram
Failed to build TgCrypto
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (TgCrypto)
make: *** [Makefile:7: install] Error 1