How to give permission to access mounted usb files in python using an android device? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to give permission to access mounted usb files in python using an android device?

I'm currently using Pydroid 3 to execute my python scripts in an android device but I get permission denied error when I try to reach a file on my mounted usb. I really would appreciate if someone could help with the issue.

26th Jun 2021, 5:00 AM
AI Machine
AI Machine - avatar
7 Answers
+ 1
And sadly, "Full read-write access to external SD cards and USB drives is available only on rooted devices." - wiki.termux.com Soooo either root your device or copy your scripts locally and mabey try keeping them there. I keep mine in my downloads folder for instance
26th Jun 2021, 6:37 AM
Slick
Slick - avatar
+ 2
No it doesn't look like it, ends up being a huge permissions issue. It mentions that you CAN have some sort of private termux folder held on external sd, but it also says there is no chown, chmod, etc in that private external folder unless rooted. Root is easier and easier every day. Many tools are availible but i suggest adb platform tools and magisk for a clean and pretty simple install. Just read up on your devices root process
26th Jun 2021, 7:21 AM
Slick
Slick - avatar
+ 2
I know this is 6 months old but I wanted to say that I was having issues until I did these things... Formatted my usb thumb drive in android. Removed my old /storage folder in termux. Then rerun termux-usb -l get your device and termux-usb -r (device). Last termux-setup-storage and a new folder external-1 finally appeared and would not until I started fresh. Unrooted and I can read and write to the usb drive no issues.
3rd Jan 2022, 8:25 AM
Michael Rutherford
+ 1
termux-setup-storage and then give file access rights to termux cd ~/storage ls Now you should be in your phones internal storage. You can copy any files to your internal storage and then mess with them from there
26th Jun 2021, 6:29 AM
Slick
Slick - avatar
+ 1
Why can't you just copy paste files from SD to local storage? I guess it is not a big in size as we are talking about python script files. Which are less than average mp3 file size.
26th Jun 2021, 6:35 AM
Shadoff
Shadoff - avatar
0
Shadoff of course I can but It's time taking and that's why I wanted to know if there is a way to access directly to the usb storage through the script.
26th Jun 2021, 7:05 AM
AI Machine
AI Machine - avatar
0
Slick Thanks a lot for your information. Can I only read a file's name located on a usb storage through termux if the device is not rooted?
26th Jun 2021, 7:15 AM
AI Machine
AI Machine - avatar