Skip to content
Advertisement

ValueError: Could not find a default download directory of nltk

I have problem on import nltk. I configured apache and run some sample python code, it worked well on the browser. The URL is : /localhost/cgi-bin/test.py. When I import the nltk in test.py its not running. The execution not continue after the “import nltk” line.And it gives me that error ValueError: Could not find a default download directory But when I run in the command prompt its working perfect. how to remove this error?

Advertisement

Answer

The Problem is raised probably because you don’t have a default directory created for your ntlk downloads. If you are on a Windows Platform, All you need to do is to create a directory named “nltk_data” in any of your root directory and grant write permissions to that directory. The Natural Language Tool Kit initially searches for the destination named “nltk_data” in all of the root directories.

For Instance: Create a folder in your C: drive named “nltk_data”

After Making sure everything is done fine, execute your script to get rid of this error.

Hope this helps.

Regards.

Advertisement