4

I happen to have some unused/obsolete python libraries in System directory, especially in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python, the issue is that I can't delete any file in the library anymore. I guess it's happening after upgrading to 10.11.

I tried sudo rm -rf, but I just can't delete any file in it.

python> sudo rm -rf *.pyc
Password:
rm: easy_install.pyc: Operation not permitted
rm: pkg_resources.pyc: Operation not permitted
rm: pylab.pyc: Operation not permitted
rm: pyparsing.pyc: Operation not permitted
rm: six.pyc: Operation not permitted

enter image description here

What might be done to remove them?

10

Do not touch the System directory! Those are files that the system may or may not need in the future (or currently). OS X uses Python, so just because you may not need the module, that doesn't mean that OS X doesn't. Really, this is why they created SIP in the first place.

  • 1
    +1 These files are NOT "unused/obsolete", they're part of a standard install of El Capitan and should not be messed with. I would disagree with this being the reason SIP was created, though -- it's not really intended to protect users from themselves, it's primarily a security layer to limit the kinds of damage malware can do if it gets root. – Gordon Davisson Nov 6 '15 at 20:41
  • 2
    Well, I'd say there were at least a few reasons. Certainly it's hugely advantageous as a layer that protects the system from processes that do bad things with root access, but the amount of people I see on the internet asking for help with what's analogous to surgery on a computer, who seem to know very little about the computer they're operating on, tells me that SIP will, without a doubt, result in a great decrease in a large portion of common corruption scenarios. – William T Froggard Nov 6 '15 at 20:46
  • 6 months later and the answer to every question is "Disable SIP and then you can do the thing you want to." – blanket_cat Apr 5 '17 at 8:10
  • These answers and comments are so frustrating! I look up Apple community, then Apple StackExchange, etc. The answers are always "don't you dare!". How about explaining the reason? I am a coder, I install things sometimes at the system level, including things that get installed into the System/Library path. Now, like the OP, I would like to clean them up. There is no acceptable way that Apple has allowed. Which leads to their ultimate goal: we all collectively decide our computers "have become" too slow and we need to buy another (or do a fresh install). Frustrating!! – Mike Williamson Dec 20 '17 at 16:48
  • @MikeWilliamson You don't install anything into the /System/Library directory usually, unless the software you're using was written poorly. /Library is supposed to be used for anything system-wide, not /System/Library. – William T Froggard Dec 20 '17 at 16:55
6

The directories are protected by System Integrity Protection in OS X El Capitan.

In order to disable it:

  1. Reboot & hold Cmd ⌘ R at the chimes
  2. Open Terminal
  3. Type csrutil disable; reboot

Hints from http://osxdaily.com/2015/10/05/disable-rootless-system-integrity-protection-mac-os-x/

It isn't advisable to actually do this, however. Deleting files in the System directory could have unforeseeable and potentially disastrous consequences.

  • 8
    I given a +1 for answering the question correctly and giving a reference etc, but I think you might add "DON'T DO THIS UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!!!!" – Iain Nov 6 '15 at 17:43
  • @lain, What's that file needed for anyway? – Pacerier May 29 '18 at 14:29
5

These aren't your files. You absolutely do not understand what you are doing. Other people have already told you this, but not what you actually need to do instead.

Here is a decent rundown on how to set up your own parallell python installation with Homebrew, and then virtualenv on top of that so you don't run into conflicts.

The only reason anyone should ever touch /System is if they're running a hackintosh.

Edit: using pip with virtualenv is what you should do by default anyways. It's not a last resort for when you run into issues.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .