Error configuring virtualenv using Python 3

I try to create virtualenv (using virtualenvwrapper) with Python 3 as the default interpreter, but keep getting the same error after 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 (pre-packaged version for OS X) and Python 3 (via brew install python3).

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

+4
source share
1 answer

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

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

After that it virtualenvworked properly.

+1
source

Source: https://habr.com/ru/post/1585029/


All Articles