Mac virtualenv创建新环境报错

前言:Mac,已经安装好virtualenv


但是创建沙箱环境的时候报错,报错信息如下:


Arons-MacBook-Pro:virtualenv_tensorflow aron$ virtualenv venv_tensorflow

New python executable in /Users/aron/Documents/work_python/virtualenv_tensorflow/venv_tensorflow/bin/python
Installing setuptools, pip, wheel...
  Complete output from command /Users/aron/Document...ensorflow/bin/python - setuptools pip wheel:
  Traceback (most recent call last):
  File "", line 4, in 
  File "/Users/aron/anaconda/lib/python2.7/tempfile.py", line 32, in 
    import io as _io
  File "/Users/aron/anaconda/lib/python2.7/io.py", line 51, in 
    import _io
ImportError: dlopen(/Users/aron/Documents/work_python/virtualenv_tensorflow/venv_tensorflow/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: /Users/aron/Documents/work_python/virtualenv_tensorflow/venv_tensorflow/lib/python2.7/lib-dynload/_io.so
  Expected in: flat namespace
 in /Users/aron/Documents/work_python/virtualenv_tensorflow/venv_tensorflow/lib/python2.7/lib-dynload/_io.so
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/Users/aron/anaconda/bin/virtualenv", line 11, in 
    sys.exit(main())
  File "/Users/aron/anaconda/lib/python2.7/site-packages/virtualenv.py", line 713, in main
    symlink=options.symlink)
  File "/Users/aron/anaconda/lib/python2.7/site-packages/virtualenv.py", line 945, in create_environment
    download=download,
  File "/Users/aron/anaconda/lib/python2.7/site-packages/virtualenv.py", line 901, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/Users/aron/anaconda/lib/python2.7/site-packages/virtualenv.py", line 797, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/aron/Document...ensorflow/bin/python - setuptools pip wheel failed with error code 1


解决方法:

(1)先执行  conda install python=2.7.9 降级版本

(2)再执行 virtualenv venv


OK,大功告成!!

参考:https://github.com/conda/conda/issues/1367


备注:本机的python 2.7, 安装了anaconda(默认)


你可能感兴趣的:(python)