Virtualenv breaks if python-configparser is installed

Bug #1156704 reported by Thomi Richards
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
python-virtualenv (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

The virtualenv package fails when the python-configparser is installed and I try and create a python3.3 virtualenv:

 virtualenv --system-site-packages -v -p python3.3 ve3
Running virtualenv with interpreter /usr/bin/python3.3
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 42, in <module>
    import ConfigParser
ImportError: No module named 'ConfigParser'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 44, in <module>
    import configparser as ConfigParser
  File "/usr/share/pyshared/configparser.py", line 398
    _KEYCRE = re.compile(ur"%\(([^)]+)\)s")
                                         ^
SyntaxError: invalid syntax
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 64, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/share/pyshared/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/share/pyshared/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/share/pyshared/apport/fileutils.py", line 15, in <module>
    from configparser import ConfigParser, NoOptionError, NoSectionError
  File "/usr/share/pyshared/configparser.py", line 398
    _KEYCRE = re.compile(ur"%\(([^)]+)\)s")
                                         ^
SyntaxError: invalid syntax

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 42, in <module>
    import ConfigParser
ImportError: No module named 'ConfigParser'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 44, in <module>
    import configparser as ConfigParser
  File "/usr/share/pyshared/configparser.py", line 398
    _KEYCRE = re.compile(ur"%\(([^)]+)\)s")
                                         ^
SyntaxError: invalid syntax

This is because virtualenv re-executes itself with the target python version, but runs the virtualenv.py file in /usr/lib/python2.7/dist-packages, which in turn adds that directory to sys.path. Since I have the configparser module installed, it tries to import the v2 version of that module, which then fails with a SyntaxError

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-virtualenv (Ubuntu):
status: New → Confirmed
Revision history for this message
Barry Warsaw (barry) wrote :

Crap. Now that python-configparser is required by configglue, which is required by ubuntuone, I guess I have to actually fix this now. Note how Software Center got equally broken in LP: #1038429

Revision history for this message
Barry Warsaw (barry) wrote :
Revision history for this message
Barry Warsaw (barry) wrote :

This doesn't appear to still be a problem with configparser 3.3.0r2-2 in Vivid. There's a newer version on PyPI which will hopefully get into Debian after Jessie and then W, but it still seems to no longer be a problem afaict.

Changed in python-virtualenv (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Casey Marshall (cmars) wrote :

This is still broken on trusty.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.