What Directory Does Chaquopy Code Search For The Python Packages Which Are Imported In The Python Code Of The Android App Code
I have imported nltk library in my main method of the Python code of the chaquopy Android app. It is asking me to implement nltk.download('punkt') for my processing. So I wanted to
Solution 1:
Chaquopy 4.0.0 and newer
These versions set the HOME environment variable to your app's files directory, and nltk will automatically create an nltk_data subdirectory there. So no special action is required.
Chaquopy 3.3.2 and older
I think the cleanest solution would be to create a separate directory for your downloads, like this:
from com.chaquo.python import Python
download_dir = "{}/nltk".format(Python.getPlatform().getApplication().getFilesDir())
ifnotos.path.exists(download_dir):
os.mkdir(download_dir)
nltk.download(..., download_dir=download_dir)
(The getPlatform method requires Chaquopy 3.2.0 or later.)
From the NLTK documentation, it looks like you'll have to set the NLTK_DATAenvironment variable to this directory. This should probably be done before you import nltk.
Post a Comment for "What Directory Does Chaquopy Code Search For The Python Packages Which Are Imported In The Python Code Of The Android App Code"