[Distutils] Virtualenv bug breaking tox runs

Marius Gedminas marius at gedmin.as
Wed Jul 15 08:08:57 CEST 2015

On Wed, Jul 15, 2015 at 12:55:50AM -0400, Randy Syring wrote:
> I'm trying to use tox from python2 to test a python3 environment. But I get
> an exception like the following:
> >rsyring at loftex:~/projects/blaze/blazeutils-src$ python -m virtualenv
> >--python python3 ~/tmp/testvenv
> >Running virtualenv with interpreter /home/rsyring/bin/python3
> >Traceback (most recent call last):
> >  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 14, in
> ><module>
> >    import shutil
> >  File "/opt/python34/lib/python3.4/shutil.py", line 11, in <module>
> >    import fnmatch
> >  File "/opt/python34/lib/python3.4/fnmatch.py", line 15, in <module>
> >    import functools
> >  File "/opt/python34/lib/python3.4/functools.py", line 21, in <module>
> >    from collections import namedtuple
> >  File "/opt/python34/lib/python3.4/collections/__init__.py", line 17, in
> ><module>
> >    from reprlib import recursive_repr as _recursive_repr
> >  File "/usr/local/lib/python2.7/dist-packages/reprlib.py", line 3, in
> ><module>
> >    from repr import *
> >ImportError: No module named 'repr'
> There is a bug for this in virtualenv:
>     https://github.com/pypa/virtualenv/issues/625
> So, I realize I could use `python3 -m virtualenv` if I was running the
> command myself.  But, tox is making the call to virtualenv.
> This was working the last time I tested it but has now broken.  I'm guessing
> that is because I upgraded tox or virtualenv?

It broke now because you 'sudo pip install'ed something that depends on
something that ships /usr/local/lib/python2.7/dist-packages/reprlib.py
(which probably comes from pies2overrides)

> Any pointers welcome as to the best way to resolve this issue now?

I would recommend sudo pip uninstall pies2overrides (and whatever
depended on it).  A good way to avoid pain is to never ever 'sudo pip
install' stuff.

A different workaround would be to create a clean virtualenv, install
tox into it, then run tox from that virtualenv.

Marius Gedminas
Un*x admins know what they are doing by definition.
        -- Bernd Petrovitsch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 173 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20150715/6a4b7ddd/attachment.sig>

More information about the Distutils-SIG mailing list