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.

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

1 Answers1

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.

vmarquet
  • 2,384
  • 3
  • 25
  • 39