1

I am trying to follow the advice here: Jython: ImportError: No module named multiarray( but when I try to change and save the nltk/metrics/segmentation.py file in eclipse (under ubuntu 11) I get

Parent of resource: /usr/local/lib/python2.7/dist-packages/nltk/metrics/segmentation.py is marked as read-only. /usr/local/lib/python2.7/dist-packages/nltk/metrics/segmentation.py (Permission denied) i've tried chmod 777 -r but that does not do anything.

Can anyone help a noob in over his depth?

Community
  • 1
  • 1
schoon
  • 2,858
  • 3
  • 46
  • 78
  • I am going to try Running eclipse as sudo Or Copying nltk to another directory and add that to pythonpath. What do you reckon? – schoon Oct 25 '12 at 15:39
  • Don't run as sudo, you can really mess things up that way. Find a way to run as a normal user. "Parent of resource" might mean the directory (metrics), check its permissions. – alexis Oct 26 '12 at 22:27

1 Answers1

1

Chmod's recursive is with a capital "R" and the option -R comes before the permissions, which themselves come before the directory. Thus:

sudo chmod -R 777 dir/name

should do what you want.

However, I always have trouble telling people to go chmodding 777 willy-nilly.

All directories outside of your home directory are read-only by default. There are three types of privileges: "read", "write", "execute" for three sets of users. If you run the command ls -l on the directories in question, you should see something like this:

drwxr-xr-x    4 shannon  admin   136 Oct  7 18:22 chunkers/
drwxr-xr-x  122 shannon  admin  4148 Nov  1 08:22 corpora/
drwxr-xr-x   12 shannon  admin   408 Nov  1 08:22 grammars/

The security of a Linux system is primarily based on the fact that only root can do anything. Everyone else, including your username, has to ask for permission. This may seem like a hassle, but we Linux users are happy that everyone has to ask permission.

So, what does this crap mean:

drwxr-xr-x 4 shannon admin some-numbers date-time dir/name
  1. drwx: This is a 'd' (directory) that user/owner (shannon) can do the following for rwx.
  2. r-x: Group (in this case admin) can do the following: rx (read and execute, not write).
  3. r-x: Others (anybody other users) can do the following: rx.

et cetera.

To edit that file, you can permanently change owner of the directory in question to yourself:

sudo chown -R yourusername /usr/local/lib/python2.7/dist-packages/nltk/

Of course, there are many different ways you can give yourself permission to edit stuff (for instance, you can sudo chgrp -R g+w dir/name and then make sure your username is part of the group that can now write to the directory). This is a nice way to make it so that others can do things to do this directory.

Probably the best solution is to edit the file using sudo and a command-line editor, because you probably won't be editing the file multiple times, will you?

sudo nano /usr/local/lib/python2.7/dist-packages/nltk/metrics/segmentation.py

Use CTRL+o to save and CTRL+x to exit.

Anyway, some answers are less secure than others, but I've always been hesitant to chmod 777 everything. Maybe I was taught to be too paranoid.

erewok
  • 7,555
  • 3
  • 33
  • 45