SecretWeb
SecretWeb

Reputation: 23

nltk download error13 Permission denied mac

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'

Upvotes: 1

Views: 2670

Answers (2)

alexis
alexis

Reputation: 50220

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.

Upvotes: 2

meyer9
meyer9

Reputation: 1140

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/

Upvotes: 3

Related Questions