在阿里云ubuntu服务器布置Django项目中出现如下错误:
Resource stopwords not found.
Please use the NLTK Downloader to obtain the resource:
具体如下所示:
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/root/.virtualenvs/T/lib/python3.5/site-packages/nltk/corpus/util.py", line 86, in __load
root = nltk.data.find('{}/{}'.format(self.subdir, zip_name))
File "/root/.virtualenvs/T/lib/python3.5/site-packages/nltk/data.py", line 701, in find
raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource stopwords not found.
Please use the NLTK Downloader to obtain the resource:
>>> import nltk
>>> nltk.download('stopwords')
For more information see: https://www.nltk.org/data.html
Attempted to load corpora/stopwords.zip/stopwords/
Searched in:
- '/root/nltk_data'
- '/root/.virtualenvs/T/nltk_data'
- '/root/.virtualenvs/T/share/nltk_data'
- '/root/.virtualenvs/T/lib/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
**********************************************************************
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/core/management/base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/urls/resolvers.py", line 399, in check
for pattern in self.url_patterns:
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/urls/resolvers.py", line 584, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/root/.virtualenvs/T/lib/python3.5/site-packages/django/urls/resolvers.py", line 577, in urlconf_module
return import_module(self.urlconf_name)
File "/root/.virtualenvs/T/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "" , line 986, in _gcd_import
File "" , line 969, in _find_and_load
File "" , line 958, in _find_and_load_unlocked
File "" , line 673, in _load_unlocked
File "" , line 665, in exec_module
File "" , line 222, in _call_with_frames_removed
File "/home/recommend_system-master/recommend_system/urls.py", line 18, in <module>
import movie_recommend.views
File "/home/recommend_system-master/movie_recommend/views.py", line 15, in <module>
from movie_recommend.load_data import *
File "/home/recommend_system-master/movie_recommend/load_data.py", line 19, in <module>
stoplist = stopwords.words('english')
File "/root/.virtualenvs/T/lib/python3.5/site-packages/nltk/corpus/util.py", line 123, in __getattr__
self.__load()
File "/root/.virtualenvs/T/lib/python3.5/site-packages/nltk/corpus/util.py", line 88, in __load
raise e
File "/root/.virtualenvs/T/lib/python3.5/site-packages/nltk/corpus/util.py", line 83, in __load
root = nltk.data.find('{}/{}'.format(self.subdir, self.__name))
File "/root/.virtualenvs/T/lib/python3.5/site-packages/nltk/data.py", line 701, in find
raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource stopwords not found.
Please use the NLTK Downloader to obtain the resource:
>>> import nltk
>>> nltk.download('stopwords')
For more information see: https://www.nltk.org/data.html
Attempted to load corpora/stopwords
Searched in:
- '/root/nltk_data'
- '/root/.virtualenvs/T/nltk_data'
- '/root/.virtualenvs/T/share/nltk_data'
- '/root/.virtualenvs/T/lib/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
**********************************************************************
ubuntu中打开python3解释器
>>>python3
>>> import nltk
>>> nltk.download('stopwords')
再次重启Django项目即可正确运行