I want to get the DCIM folder path in android using kivy.
I tried using this code:
from kivy.app import user_data_dir
from os.path import dirname, join
dcim = join(dirname(user_data_dir), 'DCIM')
print(dcim)
I got this code from this stack: Kivy - get the path to DCIM folder on any android device
The error I see:
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3 /Users/sanjayshreeyansgmail.com/PycharmProjects/Scrach/Furbase.py
[INFO ] [Logger ] Record log in /Users/sanjayshreeyansgmail.com/.kivy/logs/kivy_21-04-26_30.txt
[INFO ] [Kivy ] v2.0.0
[INFO ] [Kivy ] Installed at "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kivy/__init__.py"
[INFO ] [Python ] v3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18)
[Clang 6.0 (clang-600.0.57)]
[INFO ] [Python ] Interpreter at "/Library/Frameworks/Python.framework/Versions/3.8/bin/python3"
[INFO ] [Factory ] 186 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
Traceback (most recent call last):
File "/Users/sanjayshreeyansgmail.com/PycharmProjects/Scrach/Furbase.py", line 1, in <module>
from kivy.app import user_data_dir
ImportError: cannot import name 'user_data_dir' from 'kivy.app' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kivy/app.py)
pls help me.
Try this:
from kivy.app import App
from os.path import dirname, join
dcim = join(dirname(App().user_data_dir), 'DCIM')
print(dcim)
The user_data_dir
is a property of App
, so you must have an instance of App
in order to access it. It is not a class attribute. If your code involves an App
, use that App
instance to access user_data_dir
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.