我在mac OS X的终端上输入nltk.download()
后运行了命令python3
。然后我收到此错误
PermissionError: [Errno 13] Permission denied: '/Users/shreya/nltk_data/corpora/panlex_swadesh.zip'
这是我在终端上得到的:
>>> nltk.download()
showing info https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml
Exception in thread Thread-1:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nltk/downloader.py", line 1867, in run
for msg in self.data_server.incr_download(self.items):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nltk/downloader.py", line 529, in incr_download
for msg in self._download_list(info_or_id, download_dir, force):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nltk/downloader.py", line 572, in _download_list
for msg in self.incr_download(item, download_dir, force):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nltk/downloader.py", line 543, in incr_download
for msg in self.incr_download(info.children, download_dir, force):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nltk/downloader.py", line 529, in incr_download
for msg in self._download_list(info_or_id, download_dir, force):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nltk/downloader.py", line 572, in _download_list
for msg in self.incr_download(item, download_dir, force):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nltk/downloader.py", line 549, in incr_download
for msg in self._download_package(info, download_dir, force):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nltk/downloader.py", line 600, in _download_package
os.remove(filepath)
PermissionError: [Errno 13] Permission denied: '/Users/shreya/nltk_data/corpora/panlex_swadesh.zip'
答案 0 :(得分:2)
您对此文件的权限有误。您需要使用sudo执行脚本,或者最好通过运行此命令来更改权限:
sudo chmod +rwx /Users/shreya/nltk_data/corpora/panlex_swadesh.zip
此外,如果要更改目录中的所有权限,可以运行:
sudo chmod -R +rwx /Users/shreya/nltk_data/
答案 1 :(得分:0)
出于某种原因,您的python下载过程无权将文件下载到nltk_data
目录中。这很清楚。由于后者位于您的主目录下(假设您 用户shreya
),因此无法确定可能出现的问题。您可以编辑您的答案以提供更多信息,包括您正在运行的OS X版本以及可能与您的环境相关的任何其他信息。
您也可以尝试不同的方法:
nltk_data
文件夹,退出并重新启动Python,然后重试。idle
或idle3
)并在IDLE控制台中运行您的python代码。也许其中一个会起作用。如果没有,您将 以提供更多信息。