122

I seem to have suddenly started to encounter the error error: option --single-version-externally-managed not recognized when using pip install with various packages (including PyObjC and astropy).

I've never seen this error before, but it's now also showing up on travis-ci builds for which nothing has changed.

Does this error indicate an out of date distribution?

Some incorrectly specified option in setup.py?

Something else entirely?

David Medinets
  • 5,160
  • 3
  • 29
  • 42
keflavich
  • 18,278
  • 20
  • 86
  • 118

7 Answers7

135

Add --egg option

pip install --egg SCons

I use pip version 1.4.1

frogatto
  • 28,539
  • 11
  • 83
  • 129
wynemo
  • 2,293
  • 2
  • 19
  • 10
  • 10
    That was the only solution that actually helped. Recent pip and setuptools were already installed, nevertheless I hat this error. – Michael Jan 24 '15 at 10:53
  • I had this problem with pyenv and this fixed it. – glaucon May 14 '15 at 01:47
  • 20
    Can someone explain in detail what does this option mean and why does this work? – kawing-chiu Apr 18 '16 at 07:07
  • 4
    While this worked for me, I also got the error: "DEPRECATION: --egg has been deprecated and will be removed in the future. This flag is mutually exclusive with large parts of pip, and actually using it invalidates pip's ability to manage the installation process." – natersoz Mar 16 '17 at 20:19
  • Thanks for the tip. On older version of Ubuntu, mysql-connector-rf refused to insall using pip. None of the other answers worked, and since I had no way of upgrading the OS, I tryed --egg, and voila ! – Yannick Mauray Aug 02 '17 at 13:25
  • 12
    `no such option: --egg` in pip 18.1 – gdw2 Oct 19 '18 at 23:09
114

New Update:

Install the latest version of setuptools. If you still get the error, install wheel as well.

pip install -U setuptools
pip install -U wheel

Original Answer / More Details:

--single-version-externally-managed is an option used for Python packages instructing the setuptools module to create a Python package which can be easily managed by the host's package manager if needed, like Yum or Apt.

If you're seeing this message, you may have an old version of setuptools or Python. Try using Distribute, which is a newer version of setuptools and is backwards compatible. These packages may expect that you have it already.

https://pypi.python.org/pypi/distribute

Edit: At this point, distribute has been merged into the main setuptools project. Just install the latest version of setuptools. As @wynemo indicated, you may wish to use the --egg option instead, as it's more appropriate for those doing manual installations where you're not intending to create a system package for distribution.

ADTC
  • 8,999
  • 5
  • 68
  • 93
Kelketek
  • 2,406
  • 5
  • 21
  • 28
  • 1
    Can you add which version that showed up in? I'm using setuptools 0.6 and pip doesn't know about a newer version. `distribute` sounds right, but I can't import it... – keflavich Mar 07 '13 at 00:35
  • You don't `import distribute`. Distribute is a drop-in replacement and has the same module name. `import setuptools` is needed for it as well. – Kelketek Mar 07 '13 at 03:39
  • The thing to do, then, is to make sure setuptools is not overriding distribute, if you have both installed. You should install distribute with pip, and then remove setuptools. I imagine that should work. – Kelketek Mar 07 '13 at 04:12
  • 17
    It should be added: Don't use distribute anymore. Distribute has been merged back into the setuptools project, so now there is just one `setuptools` to rule them all. – Iguananaut Sep 03 '13 at 15:33
  • 1) People should not be encouraged to use `distribute`. 2) this doesn't work, instead the `--egg` option worked for me, as suggested in @wynemo's answer. – 0 _ Sep 05 '14 at 23:48
  • 1
    @johntex, this answer was made over a year ago, when distribute and setuptools had not yet merged (or if they had, I'd not heard of it). I have updated it now. – Kelketek Sep 06 '14 at 03:00
  • Besides the possibly old versions of setuptools or python, installing `wheel` as said in Seth's answer. Also solved the issue and it seems better than adding the `--egg` option. – Vargas Nov 24 '16 at 12:16
  • 3
    Neither works for me in 2020. `--egg` option is gone, and I have the latest `setuptools` and `wheel` installed, and still get this error :(. Maybe I need to recreate my conda environment. – LOST May 05 '20 at 17:52
  • Same as LOST. `--egg` is no longer and `setuptools` and `wheel` are installed and up to date. – A. Vieira Nov 03 '20 at 09:50
  • it worked for me. i have pip 18.1 with python 3.7. upgrade `setuptools` then add `wheel`. – Amit Kumar May 12 '21 at 06:40
50

Installing wheel resolved this issue with recent pip (I used 8.1.2):

pip install wheel
anatoly techtonik
  • 19,847
  • 9
  • 124
  • 140
Seth Difley
  • 1,330
  • 1
  • 23
  • 33
  • You can revert to edit if you like, no problem. If you know the exact version of `pip` and `wheel` where it was fixed, it may worth to mention it in case it will be broken again. And also, the answer doesn't explain what is going on anyway. – anatoly techtonik Oct 01 '16 at 04:34
  • This plus answer from @sparrowt fixed my issue – David Poxon Jan 07 '17 at 00:58
  • Fixed the issue for me (python 3.10.2, pip 21.3.1, Win 10 20H2 build 19042.870) – Piotr L Jan 19 '22 at 12:35
9

Try upgrading setuptools like this:

pip install --upgrade setuptools

sparrowt
  • 2,641
  • 25
  • 24
5

I was having this problem. It turned out it was a problem with the file permissions on my pip cache.

If you see a message at the very beginning of your pip output like

The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

you might have the same problem. You can resolve it by either ensuring that you have proper file permissions on your pip cache (something like chown -R $(whoami) /home/ubuntu/.cache/pip) or, if you're on a UNIX, you can set the pip cache location with the XDG_CACHE_HOME env var to some folder you do own.

sans
  • 2,159
  • 4
  • 20
  • 22
  • Surprisingly, it worked for me too (if you use `sudo` to install the package, make sure to add the `-H` flag)! I really do not see what the connection is between the cache and the command option error, but never mind. – Delgan Sep 14 '17 at 12:19
2

I tried the above solutions. However, I only can resolve the problem until I do:

sudo pip3 install -U pip (for python3)

Karim
  • 252
  • 1
  • 4
  • 17
0

I have this problem on my macbook also when I try to upgrade one python package. I check pip version in OS X, it's too old: 1.1. I use follow cmd to upgrade pip to 1.5.6

easy_install -U pip

Then this error is fixed.

NewPtone
  • 3,075
  • 1
  • 17
  • 10