I'm working on OSX and I'm trying to create a virtualenv with Python3, but I'm getting an error:

$ virtualenv --python python3 env
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.4/bin/python3
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 37, 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/local/lib/python2.7/site-packages/virtualenv.py", line 39, in <module>
    import configparser as ConfigParser
  File "/usr/local/lib/python2.7/site-packages/configparser.py", line 397
    _KEYCRE = re.compile(ur"%\(([^)]+)\)s")

It looks like it's looking for ConfigParser, which has been renamed configparser. Is that right? What can I do?

I've tried to update virtualenv with pip install -U virtualenvwrapper but it hasn't helped.

  • Also same problem if I do: virtualenv -p /usr/local/bin/python3 .venv – Richard Jul 22 '15 at 16:05
  • In Python 3, why not use pyvenv instead? – 200_success Jul 22 '15 at 21:47
  • This is still an issue, but only after I updated to El Capitan. I don't know if OP has similar circumstances, but I'm surprised that this didn't create an error sooner. And even after setting up pyenv, I am getting this error when i try to make a virtualenv with python3. Uninstalling and reinstalling(with both pip and pip3) virtualenvwrapper and virtualenv also did not solve the issue. – mpacer Nov 4 '15 at 2:49
  • Also — to clarify my final traceback line is instead ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted. I don't know if that may help you, but a similar uninstall and reinstall of future via pip and pip3 did nothing to resolve the issue. – mpacer Nov 4 '15 at 3:19

I had a similar issue, and I'm not certain if this will solve you problem, but for me it was due to a new version of python-future which jumped the queue in my path (ahead of the core python configparser) and then ran into issues.

What solved the problem for me was just removing the configparser.py file from that directory, since that wasn't the configparser that virtualenv is looking for.

To be fair, I think this issue was introduced in a more recent version of future (which is why I had a different error from you) but I imagine that given the path that your traceback is coming from, the issue still stems from it running into a configparser module that virtualenv doesn't expect to be there.

I'm filing an issue with the python-future folks, but other than that, I don't really know how to solve this issue other than to eliminate the version of configparser from its position on the path. Unfortunately, that also messes with future's ability to allow equivalence between import statements in python2 and python3.

Hope this helps!

| improve this answer | |

problem solved after I upgrade to latest version of virtualenv 15.1.

pip install --upgrade virtualenv
| improve this answer | |

I think virtualenv should be installed for both python2&3, so I fixed this error by installing virtualenv for python3.

sudo python3 -m pip install virtualenv
| improve this answer | |
  • It does not need to be installed as both. When calling virtualenv, only one of the two will be used. However, it does need to be up to date. – Andrew Domaszek Jun 11 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.