0

Running setup.py install for anyjson ... done Found existing installation: six 1.4.1 DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project. Uninstalling six-1.4.1: Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run prefix=options.prefix_path, File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 778, in install requirement.uninstall(auto_confirm=True) File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall paths_to_remove.remove(auto_confirm) File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove renames(path, new_path) File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames shutil.move(old, new) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move copy2(src, real_dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2 copystat(src, dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat os.chflags(dst, st.st_flags) OSError: [Errno 1] Operation not permitted: '/tmp/pip-29Cml5-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

Snippet of error stacktrace. While running requirements.txt on python. Is it due to six.

Ignoring it does NOT help.

sudo -H pip install -r requirements.txt --ignore-installed six Double requirement given: six==1.10.0 (from -r requirements.txt (line 107)) (already in six, name='six')

This post does not help - https://github.com/pypa/pip/issues/3165

R11G
  • 1,941
  • 8
  • 26
  • 37
  • 1
    i take it you're not using virtualenv here? that would be the cleanest workaround. – ingernet Apr 04 '18 at 22:17
  • @ingernet Some of Apple's `Extras` stuff will actually prevent `pip install` from working within a venv. But it's definitely worth trying that first, unless the OP can't use venvs for some reason. – abarnert Apr 04 '18 at 22:35

1 Answers1

1

Sometimes, the Extras problem I'm going to describe does not affect venvs. Sometimes it does, but if using virtualenv is at all an option, you should try that before doing anything else.

So, let's assume you either can't do that, or you tried it and this is one of the cases where it doesn't actually help.


First, let me say that all of the following is terrible, terrible advice for any purpose except installing new versions of packages that Apple pre-installed in Extras with Apple's Python 2.7 in OS X 10.7-10.13. Anyone reading this who does not have exactly that problem, stop reading now.

Apple's system version of Python 2.7 comes with a nifty set of third-party packages preinstalled in:

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/

Rather than try to keep these packages up to date, they designed things so that you can easily shadow them with a newer version in your site-packages directory. Which wasn't a terrible idea.

Unfortunately, they stopped doing any serious maintenance on this a few versions of OS X back, but didn't stop shipping it. In particular, they never updated it to work with setuptools and pip, and if you install pip properly (using the get-pip.py script instead of easy_install), shadowing installs will basically never work.


If your pre-installed easy_install is still working, it should still work to install shadowing packages. Do not use it for anything else, but for this specific purpose, it's the right tool. But it doesn't work for every package on every OS X version, so it's a bit of trial and error. You may want to back up Extras and site-packages first just in case.


The way to test it (assuming easy_install succeeds, of course—if it fails with a slew of errors, it obviously didn't work… and it's time to restore your backups) is to start Python, import six, and look at six.__version__ or six.__file__. If it's the new version in site-packages, you win.


If that doesn't work, there's a hacky workaround that may solve your problem: Temporarily move the file Extras/lib/python/six-1.4.1-py2.7.egg-info somewhere else, then see if pip install six successfully installs into your normal site-packages. If so, restore the egg-info file, and test the shadowing again.


If that still didn't work… well, you can install manually, but I think at this point, the pain of having two Python 2.7 installations in parallel is less than the pain of managing the one you have, so I'd consider installing another one (python.org, Anaconda, or Homebrew) and being careful to never touch the Apple one again (virtualenv can help with this).

abarnert
  • 354,177
  • 51
  • 601
  • 671