我正在尝试使用Python 3作为我的默认解释器创建virtualenv(使用virtualenvwrapper),但是在多次重新安装Python 3,virtualenv和virtualenvwrapper之后仍然会收到相同的错误.
$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
我安装了Python 2(OS X的预打包版本)和Python 3(通过brew install python3).
我可以使用我的任何Python 2二进制文件创建virtualenvs.
解决方法:
我有完全相同的错误,在我的情况下,我能够通过以下步骤解决它:
$brew unlink python3
$brew link --overwrite python3
$unset PYTHONPATH
在此之后,virtualenv按预期工作.