ValueError:找不到nltk的默认下载目录 [英] ValueError: Could not find a default download directory of nltk
问题描述
我在导入nltk时遇到问题. 我配置了apache并运行了一些示例python代码,它在浏览器上运行良好. URL是:/localhost/cgi-bin/test.py. 当我在test.py中导入nltk时,它没有运行. "import nltk"行之后执行不继续.它给我该错误ValueError:找不到默认的下载目录 但是,当我在命令提示符下运行时,它的工作情况非常完美. 如何清除此错误?
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?
推荐答案
出现此问题的原因可能是您没有为ntlk下载创建默认目录.如果您使用的是Windows平台,则所需要做的就是在任何根目录中创建一个名为"nltk_data"的目录,并授予对该目录的写权限.自然语言工具包最初会在所有根目录中搜索名为"nltk_data"的目标.
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.
对于实例:在C:\驱动器中创建一个名为"nltk_data"的文件夹
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.
希望这会有所帮助.
致谢.
这篇关于ValueError:找不到nltk的默认下载目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!