9

Trying to install a Python pip package (Django Rest Framework docs, drfdocs) on Mac OSX within a virtualenv:

Here are the relevant versions of pip, python, easy_install:

$ virtualenv --version
1.11.4

$ mkvirtualenv test
New python executable in test/bin/python
Installing setuptools, pip...done.

(test)$ python --version; which python
Python 2.7.10
/Users/me/.virtualenvs/test/bin/python

(test)$ pip --version; which pip
pip 1.5.4 from /Users/me/.virtualenvs/test/lib/python2.7/site-packages (python 2.7)
/Users/me/.virtualenvs/test/bin/pip

(test)$ easy_install --version; which easy_install
setuptools 2.2
/Users/me/.virtualenvs/test/bin/easy_install

(test)$ python -c "import setuptools.command; print setuptools.command"
<module 'setuptools.command' from '/Users/me/.virtualenvs/test/lib/python2.7/site-packages/setuptools/command/__init__.pyc'>

And here's the error:

$ pip install drfdocs
Downloading/unpacking drfdocs
  Downloading drfdocs-0.0.11.tar.gz (771kB): 771kB downloaded
  Running setup.py (path:/Users/me/.virtualenvs/test/build/drfdocs/setup.py) egg_info for package drfdocs
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
    ImportError: No module named setuptools.command
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 3, in <module>

ImportError: No module named setuptools.command

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /Users/me/.virtualenvs/test/build/drfdocs
Storing debug log for failure in /Users/me/.pip/pip.log

I tried a variety of fixes from other Stack Overflow answers here, but none worked.

$ pip install -U setuptools

did not help either.


EDIT: As requested:

(test)$ python -c "import setuptools; print setuptools.__file__; print setuptools.__version__"
/Users/me/.virtualenvs/test/lib/python2.7/site-packages/setuptools/__init__.pyc
2.2

EDIT #2: I tried pip install pip --upgrade so now I'm on pip==8.1.2.

Now when I try to install I get a slightly different error:

(test)$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools
>>> exit()
(test)$ pip --version
pip 8.1.2 from /Users/me/.virtualenvs/test/lib/python2.7/site-packages (python 2.7)
(test)$ pip install drfdocs
Collecting drfdocs
  Using cached drfdocs-0.0.11.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named setuptools

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/kc/00fkv5q91vz815b2jycc8cv40000gn/T/pip-build-olnkAD/drfdocs/

Still doesn't make sense why this is happening though.

Community
  • 1
  • 1
lollercoaster
  • 15,969
  • 35
  • 115
  • 173
  • when you `pip freeze` , can you see setuptools in the outcome? – Justin M. Ucar Jul 25 '16 at 22:24
  • What is the output of this snippet from a Python interactive shell? `import setuptools; setuptools.__file__; setuptools.__version__` – Lex Scarisbrick Jul 25 '16 at 22:30
  • @Justin: no, it does not. I see only "wsgiref==0.1.2" for my "test" virtualenv. – lollercoaster Jul 25 '16 at 23:00
  • @lollercoaster Have you tried the documentation? https://pypi.python.org/pypi/setuptools there is a specific section for python 2.7 – Justin M. Ucar Jul 25 '16 at 23:06
  • @JustinM.Ucar: I think you're missing the issue. The point is that `pip` should "just work" for this mind-numbingly simple sort of task/install. There must be something wrong with my setup, but I'm not quite sure what it is. – lollercoaster Jul 26 '16 at 00:02
  • @lollercoaster i just created a virtualenv on my machine and it works OOB. It is already installed however it is not listed in `pip freeze`. The only difference i see here is the version of virtualenv. I haver it at version 15.0.1. May be your vistualenv needs upgrading? – Justin M. Ucar Jul 26 '16 at 00:23
  • @JustinM.Ucar: Running `(test)$ pip install virtualenv --upgrade; pip install drfdocs` had the same result, sadly. – lollercoaster Jul 26 '16 at 04:40
  • @lollercoaster With all the same versions, I can't replicate the error, alas. I do get that error if I try to use the setuptools included with Mac OSX, however. Perhaps pip is not inside the virtualenv? – Lex Scarisbrick Jul 26 '16 at 15:03
  • @LexScarisbrick: hmm, that would make a lot of sense. However `which pip` returns `/Users/me/.virtualenvs/test/bin/pip` and it doesn't seem like it's a symlink to anything. – lollercoaster Jul 26 '16 at 19:12
  • Have you tried: pip install --upgrade setuptools – Hendri Tobing Jul 26 '16 at 19:39
  • @HendriTobing: yes. And uninstalling and reinstalling `setuptools` as well. – lollercoaster Jul 26 '16 at 19:59
  • @lollercoaster Can you try creating your virtualenv as not hidden. Just to see if it makes any difference. `/Users/me/virtualenvs/test/` instead of `/Users/me/.virtualenvs/test/` – Justin M. Ucar Jul 26 '16 at 22:51
  • Assuming you are using bash... Have you checked whether it has cached pip? See http://unix.stackexchange.com/questions/5609/how-do-i-clear-bashs-cache-of-paths-to-executables – Peter Brittain Jul 28 '16 at 08:56
  • 1
    @lollercoaster Do you use the system default python? If so I recommend installing a real one with brew and then create a virualenv from that. – Milo Jul 29 '16 at 07:43
  • Homebrew installs Setuptools and pip for you. You may try to uninstall and reinstall your python distribution. Look at [this post](http://stackoverflow.com/a/22800774/1945707) – Tomás Gonzalez Dowling Jul 31 '16 at 19:12
  • Are you running on El Capitan? There are a number of problems installing packages when using the system-installed copy of Python on El Capitan. You may be better off installing your own copy of Python. See this answer for more details: http://apple.stackexchange.com/a/223163/143849 – Matthias Fripp Aug 04 '16 at 00:15

1 Answers1

4

This is a bug in package. See issue #120

Wait for v0.1.0 or download package from PyPI, remove site directory from this package, install patched package.

Tomasz Jakub Rup
  • 10,502
  • 7
  • 48
  • 49