4

I'm attempting to create a virtualenv (using virtualenvwrapper) with Python 3 as my default interpreter, but keep receiving the same error after un/reinstalling Python 3, virtualenv, and virtualenvwrapper several times.

$ mkvirtualenv -p /usr/local/bin/python3 test-env
Running virtualenv with interpreter /usr/local/bin/python3
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 23, in <module>
    import subprocess
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 405, in <module>
    import _posixsubprocess
ImportError: dlopen(/Library/Python/2.7/site-packages/_posixsubprocess.so, 2): Symbol not found: _PyString_AsString
  Referenced from: /Library/Python/2.7/site-packages/_posixsubprocess.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/_posixsubprocess.so

I have both Python 2 (prepackaged version for OS X) and Python 3 (via brew install python3) installed.

I can create virtualenvs fine using any of my Python 2 binaries.

3
  • Try adding the argument --no-site-packages -> mkvirtualenv -p /usr/local/bin/python3 --no-site-packages test-env
    – halex
    Commented Apr 28, 2015 at 5:53
  • 3
    Seeing the exact same error unfortunately. I've attempted a few variations (pyenv installations and fussing with PYTHONPATH) to no avail... Commented Apr 29, 2015 at 5:42
  • I'm having the same issue. I've created an issue on virtualenv's GitHub repo: github.com/pypa/virtualenv/issues/779. Commented Aug 1, 2015 at 0:47

1 Answer 1

2

I had the exact same error, and in my case I was able to solve it with the following steps:

$ brew unlink python3
$ brew link --overwrite python3
$ unset PYTHONPATH

After that, virtualenv worked as expected.

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