nltk download error13 Permission denied mac

天涯浪子 提交于 2020-03-26 10:18:19

问题


I ran the command nltk.download() after typing python3 on terminal in mac OS X. Then I am getting this error

PermissionError: [Errno 13] Permission denied: '/Users/shreya/nltk_data/corpora/panlex_swadesh.zip'

This is what I got on terminal:

>>> 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'

回答1:


For some reason, your python download process does not have the right to download files into your nltk_data directory. That much is clear. Since the latter is under your home directory (assuming that you are user shreya), there is no telling what may have gone wrong. You could edit your answer to provide more information, including the OS X version you are running, and anything else about your environment that might be relevant.

You can also try different approaches:

  1. Remove the entire nltk_data folder, quit and restart Python, and try again.
  2. Direct the interactive downloader to put the files in a different directory (see the field at the bottom).
  3. Start IDLE (e.g. by typing idle or idle3 at the Terminal) and run your python code in the IDLE console.

Maybe one of these will work. If not, you'll have to provide more information.




回答2:


Your permissions on this file are wrong. You either need to execute the script with sudo, or preferably, change the permissions by running this command:

sudo chmod +rwx /Users/shreya/nltk_data/corpora/panlex_swadesh.zip

Also, if you want to change all of the permissions in the directory, you can run:

sudo chmod -R +rwx /Users/shreya/nltk_data/


来源:https://stackoverflow.com/questions/42908625/nltk-download-error13-permission-denied-mac

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!