Skip to content

Instantly share code, notes, and snippets.

@cyrillkuettel
Last active October 29, 2024 22:47
Show Gist options
  • Save cyrillkuettel/d63785cf5f4c00106ae215188c377515 to your computer and use it in GitHub Desktop.
Save cyrillkuettel/d63785cf5f4c00106ae215188c377515 to your computer and use it in GitHub Desktop.

yt-dlp termux full installation guide.md

Prepare

  1. Install Termux from Github: https://github.com/termux/termux-app/releases
  2. Download the apk and install it -> Note that installing termux from Play Store is highly discouraged.

In Termux:

pkg update
pkg upgrade

pkg install python

pip install --upgrade pip

Install yt-dlp (originated from youtube-dl)

# let's allow termux to access the phone's storage, it will ease our workflow:
pkg install termux-api
termux-setup-storage 

More info why this is needed here https://wiki.termux.com/wiki/Termux-setup-storage

This simlinks ~/storage to the default home directory.

# yt-dlp action Now we can download videos and music using yt-dlp. LIke

cd  ~/storage/downloads # note: this points to /storage/emulated/0/Download

# yt-dlp depends on ffmpeg
pkg install ffmpeg
pip install -U --no-deps yt-dlp

yt-dlp https://www.youtube.com/watch?v=dQw4w9WgXcQ

That's it! You're done

Bonus: Other useful packages

pkg install neofetch

pkg install imagemagick
pkg install git
pkg install vim 

ZSH

pkg install zsh
# set zsh to be the default shell
chsh -s zsh
# oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

ZSH plugins

pkg install build-essential 
pkg install file
pkg install curl 

cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Edit the ~/.zshrc file to include the newly installed plugins

@Bakr-Ali
Copy link

Hello! I'm having the following errors running these commands:

~/.../downloads/Termux $ virtualenv venv
PermissionError: [Errno 1] Operation not permitted: '/data/data/com.termux/files/usr/bin/python' -> '/storage/emulated/0/Download/Termux/venv/bin/python'
~/.../downloads/Termux $ source venv/bin/activate
bash: venv/bin/activate: No such file or directory

Could you help, please?

@cyrillkuettel
Copy link
Author

cyrillkuettel commented Mar 26, 2024

You can try this
And try again. This could be a mistake in the document.

cd ~/downloads
virtualenv venv
# etc... same as above

The problem is likely due to the fact that Termux does not have write permissions in the target directory where the virtual environment is being created

@Bakr-Ali
Copy link

I think you meant ~/storage/downloads? Still not working.
And Termux does have permission to write there as the last command works:

~/.../downloads/Termux $ cd ~/downloads
bash: cd: /data/data/com.termux/files/home/downloads: No such file or directory
~/.../downloads/Termux $ cd ..   
~/storage/downloads $ virtualenv venv
PermissionError: [Errno 1] Operation not permitted: '/data/data/com.termux/files/usr/bin/python' -> '/storage/emulated/0/Download/venv/bin/python'
~/storage/downloads $ cd Termux                            
~/.../downloads/Termux $ echo "test" > test1.txt

Anyway, thank you for the help. I'll use it without virtual environments.

@cyrillkuettel
Copy link
Author

Good. I updated it. No need for virtualenv 👍

@Fjorstut
Copy link

Fjorstut commented May 7, 2024

Hi. Excellent guide! However get this error:

ERROR: Failed building wheel for pycryptodomex
Failed to build brotli pycryptodomex
ERROR: Could not build wheels for brotli, pycryptodomex, which is required to install pyproject.toml-based projects

Any ideas, anyone?

Addendum: Ok, so this issue was solved by the --no-deps parameter, i.e. run 'pip install --no-deps -U yt-dlp'

@532910
Copy link

532910 commented May 16, 2024

termux/termux-packages#20039

_file="$(find $PREFIX/lib/python3.11 -name "_sysconfigdata*.py")"
rm -rf $PREFIX/lib/python3.11/__pycache__
cp $_file "$_file".backup
sed -i 's|-fno-openmp-implicit-rpath||g' "$_file"

@sergiofbsilva
Copy link

Thanks! I got successfully rickrolled 😂🚀

@melkyfb
Copy link

melkyfb commented Jul 24, 2024

Hello,

Could you please correct the package commands that I mistakenly typed as "pgk"?

Thank you for your help.

@cyrillkuettel
Copy link
Author

Could you please correct the package commands that I mistakenly typed as "pgk"?

Done.

@daiyut0ng
Copy link

`/sdcard/Download $ pkg update
pkg upgrade

pkg install python

pip install --upgrade pip
No mirror or mirror group selected. You might want to select one by running 'termux-change-repo'
Checking availability of current mirror:
[] https://mirror.bouwhuis.network/termux/termux-main: ok
Hit:1 https://mirror.bouwhuis.network/termux/termux-main stable InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
28 packages can be upgraded. Run 'apt list --upgradable' to see them.
No mirror or mirror group selected. You might want to select one by running 'termux-change-repo'
Checking availability of current mirror:
[
] https://mirror.bouwhuis.network/termux/termux-main: ok
Hit:1 https://mirror.bouwhuis.network/termux/termux-main stable InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
28 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
apt bash ca-certificates command-not-found coreutils
curl debianutils dpkg gpgv less libandroid-support
libassuan libc++ libcurl libgcrypt libgpg-error
liblz4 libnghttp2 libnghttp3 libtirpc libunbound
nano openssl patch readline termux-keyring
termux-tools zstd
28 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 9607 kB of archives.
After this operation, 319 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 libandroid-support aarch64 29 [10.9 kB]
Get:2 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 coreutils aarch64 9.5-1 [766 kB]
Get:3 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 less aarch64 661 [126 kB]
Get:4 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 zstd aarch64 1.5.6-2 [359 kB]
Get:5 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 dpkg aarch64 1.22.6-1 [309 kB]
Get:6 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 libgpg-error aarch64 1.50 [114 kB]
Get:7 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 libassuan aarch64 2.5.7-1 [71.8 kB]
Get:8 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 libgcrypt aarch64 1.10.3-2 [438 kB]
Get:9 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 gpgv aarch64 2.4.5-2 [182 kB]
Get:10 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 libc++ aarch64 27b [299 kB]
Get:11 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 liblz4 aarch64 1.10.0 [90.2 kB]
Get:12 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 libnghttp2 aarch64 1.63.0 [99.0 kB]
Get:13 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 libnghttp3 aarch64 1.5.0 [63.4 kB]
Get:14 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 ca-certificates all 1:2024.07.02 [125 kB]
Get:15 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 openssl aarch64 1:3.3.2 [2315 kB]
Get:16 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 libcurl aarch64 8.10.0 [905 kB]
Get:17 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 curl aarch64 8.10.0 [212 kB]
Get:18 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 termux-tools aarch64 1.43.4-1 [32.8 kB]
Get:19 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 termux-keyring all 3.12-1 [39.3 kB]
Get:20 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 apt aarch64 2.8.1-1 [1028 kB]
Get:21 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 readline aarch64 8.2.13 [234 kB]
Get:22 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 bash aarch64 5.2.32 [881 kB]
Get:23 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 libunbound aarch64 1.21.0 [358 kB]
Get:24 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 command-not-found aarch64 2.4.0-41 [97.2 kB]
Get:25 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 debianutils aarch64 5.20 [16.1 kB]
Get:26 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 libtirpc aarch64 1.3.5 [125 kB]
Get:27 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 nano aarch64 8.2 [228 kB]
Get:28 https://mirror.bouwhuis.network/termux/termux-main stable/main aarch64 patch aarch64 2.7.6-4 [81.7 kB]
Fetched 9607 kB in 4s (2224 kB/s)
(Reading database ... 16844 files and directories currently installed.)
Preparing to unpack .../libandroid-support_29_aarch64.deb ...
Unpacking libandroid-support (29) over (28-3) ...
Setting up libandroid-support (29) ...
(Reading database ... 16844 files and directories currently installed.)
Preparing to unpack .../coreutils_9.5-1_aarch64.deb ...
Unpacking coreutils (9.5-1) over (9.5) ...
Setting up coreutils (9.5-1) ...
(Reading database ... 16844 files and directories currently installed.)
Preparing to unpack .../archives/less_661_aarch64.deb ...
Unpacking less (661) over (633-1) ...
Setting up less (661) ...
(Reading database ... 16845 files and directories currently installed.)
Preparing to unpack .../zstd_1.5.6-2_aarch64.deb ...
Unpacking zstd (1.5.6-2) over (1.5.6) ...
Setting up zstd (1.5.6-2) ...
(Reading database ... 16849 files and directories currently installed.)
Preparing to unpack .../dpkg_1.22.6-1_aarch64.deb ...
Unpacking dpkg (1.22.6-1) over (1.22.6) ...
Setting up dpkg (1.22.6-1) ...
(Reading database ... 16849 files and directories currently installed.)
Preparing to unpack .../libgpg-error_1.50_aarch64.deb ...
Unpacking libgpg-error (1.50) over (1.49) ...
Setting up libgpg-error (1.50) ...
(Reading database ... 16849 files and directories currently installed.)
Preparing to unpack .../libassuan_2.5.7-1_aarch64.deb ...
Unpacking libassuan (2.5.7-1) over (2.5.7) ...
Setting up libassuan (2.5.7-1) ...
(Reading database ... 16849 files and directories currently installed.)
Preparing to unpack .../libgcrypt_1.10.3-2_aarch64.deb ...
Unpacking libgcrypt (1.10.3-2) over (1.10.3) ...
Setting up libgcrypt (1.10.3-2) ...
(Reading database ... 16849 files and directories currently installed.)
Preparing to unpack .../gpgv_2.4.5-2_aarch64.deb ...
Unpacking gpgv (2.4.5-2) over (2.4.5-1) ...
Setting up gpgv (2.4.5-2) ...
(Reading database ... 16849 files and directories currently installed.)
Preparing to unpack .../libc++_27b_aarch64.deb ...
Unpacking libc++ (27b) over (26b) ...
Setting up libc++ (27b) ...
(Reading database ... 16849 files and directories currently installed.)
Preparing to unpack .../liblz4_1.10.0_aarch64.deb ...
Unpacking liblz4 (1.10.0) over (1.9.4) ...
Setting up liblz4 (1.10.0) ...
(Reading database ... 16848 files and directories currently installed.)
Preparing to unpack .../libnghttp2_1.63.0_aarch64.deb ...
Unpacking libnghttp2 (1.63.0) over (1.62.1) ...
Setting up libnghttp2 (1.63.0) ...
(Reading database ... 16848 files and directories currently installed.)
Preparing to unpack .../libnghttp3_1.5.0_aarch64.deb ...
Unpacking libnghttp3 (1.5.0) over (1.3.0) ...
Setting up libnghttp3 (1.5.0) ...
(Reading database ... 16848 files and directories currently installed.)
Preparing to unpack .../ca-certificates_1%3a2024.07.02_all.deb ...
Unpacking ca-certificates (1:2024.07.02) over (1:2024.03.11-2) ...
Setting up ca-certificates (1:2024.07.02) ...
(Reading database ... 16848 files and directories currently installed.)
Preparing to unpack .../openssl_1%3a3.3.2_aarch64.deb ...
Unpacking openssl (1:3.3.2) over (1:3.2.1-1) ...
Setting up openssl (1:3.3.2) ...
(Reading database ... 16851 files and directories currently installed.)
Preparing to unpack .../libcurl_8.10.0_aarch64.deb ...
Unpacking libcurl (8.10.0) over (8.8.0) ...
Setting up libcurl (8.10.0) ...
(Reading database ... 16854 files and directories currently installed.)
Preparing to unpack .../curl_8.10.0_aarch64.deb ...
Unpacking curl (8.10.0) over (8.8.0) ...
Setting up curl (8.10.0) ...
(Reading database ... 16854 files and directories currently installed.)
Preparing to unpack .../termux-tools_1.43.4-1_aarch64.deb ...
Deleting removed mirror: europe/termux.astra.in.ua
Deleting removed mirror: south_america/mirrors.rda.run
Unpacking termux-tools (1.43.4-1) over (1.42.4) ...
Setting up termux-tools (1.43.4-1) ...
(Reading database ... 16854 files and directories currently installed.)
Preparing to unpack .../termux-keyring_3.12-1_all.deb ...
Unpacking termux-keyring (3.12-1) over (3.12) ...
Setting up termux-keyring (3.12-1) ...
(Reading database ... 16854 files and directories currently installed.)
Preparing to unpack .../apt_2.8.1-1_aarch64.deb ...
Unpacking apt (2.8.1-1) over (2.7.14) ...
Setting up apt (2.8.1-1) ...

Configuration file '/data/data/com.termux/files/usr/etc/apt/sources.list'
==> File on system created by you or by a script.
==> File also in package provided by package maintainer.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** sources.list (Y/I/N/O/D/Z) [default=N] ?
(Reading database ... 16854 files and directories currently installed.)
Preparing to unpack .../readline_8.2.13_aarch64.deb ...
Unpacking readline (8.2.13) over (8.2.10) ...
Setting up readline (8.2.13) ...
(Reading database ... 16854 files and directories currently installed.)
Preparing to unpack .../bash_5.2.32_aarch64.deb ...
Unpacking bash (5.2.32) over (5.2.26-1) ...
Setting up bash (5.2.32) ...
(Reading database ... 16854 files and directories currently installed.)
Preparing to unpack .../libunbound_1.21.0_aarch64.deb ...
Unpacking libunbound (1.21.0) over (1.20.0) ...
Setting up libunbound (1.21.0) ...
(Reading database ... 16854 files and directories currently installed.)
Preparing to unpack .../command-not-found_2.4.0-41_aarch64.deb ...
Unpacking command-not-found (2.4.0-41) over (2.4.0-29) ...
Preparing to unpack .../debianutils_5.20_aarch64.deb ...
Unpacking debianutils (5.20) over (5.19) ...
Preparing to unpack .../libtirpc_1.3.5_aarch64.deb ...
Unpacking libtirpc (1.3.5) over (1.3.4-1) ...
Preparing to unpack .../archives/nano_8.2_aarch64.deb ...
Unpacking nano (8.2) over (8.0) ...
Preparing to unpack .../patch_2.7.6-4_aarch64.deb ...
Unpacking patch (2.7.6-4) over (2.7.6-3) ...
Setting up libtirpc (1.3.5) ...
Setting up command-not-found (2.4.0-41) ...
Setting up patch (2.7.6-4) ...
Setting up nano (8.2) ...
Setting up debianutils (5.20) ...
No mirror or mirror group selected. You might want to select one by running 'termux-change-repo'
Checking availability of current mirror:
[*] https://mirror.bouwhuis.network/termux/termux-main: ok
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python is already the newest version (3.11.9-5).
python set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
ERROR: Installing pip is forbidden, this will break the python-pip package (termux).`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment