我已經在OSX系統上通過Anaconda安裝了Python 3.5。安裝並激活虛擬環境後,無法爲virtualenv加載Python 3.5解釋器
virtualenv venv
source venv/bin/activate
Python版本是Python 2.7.10。儘管允許我們在virtualenv中加載我們選擇的解釋器,但「/ usr/bin /」僅包含Python 2.6和2.7的文件夾。找出阿納康達蟒3.5路徑(/Users/Username/anaconda/lib/python3.5) 和試圖加載它,
for: virtualenv -p /Users/Username/anaconda/lib/python3.5 venv
後的代碼返回拒絕一個[錯誤13]權限
> Running virtualenv with interpreter /Users/Username/anaconda/lib/python3.5
> Traceback (most recent call last): File "/usr/local/bin/virtualenv",
> line 11, in <module>
> sys.exit(main()) File "/Library/Python/2.7/site-packages/virtualenv.py", line 790, in main
> popen = subprocess.Popen([interpreter, file] + sys.argv[1:], env=env) File
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py",
> line 710, in __init__
> errread, errwrite) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py",
> line 1335, in _execute_child
> raise child_exception
OSError: [Errno 13] Permission denied
for: virtualenv -p /Users/Username/anaconda/bin/python3.5 venv
似乎是另一種類型的錯誤...
Running virtualenv with interpreter /Users/Username/anaconda/bin/python3.5
Using base prefix '/Users/Username/anaconda'
New python executable in venv/bin/python3.5
Not overwriting existing python script venv/bin/python (you must use venv/bin/python3.5)
ERROR: The executable venv/bin/python3.5 is not functioning
ERROR: It thinks sys.prefix is '/Users/Username/.../targetfolder' (should be '/Users/Username/.../targetfolder/venv')
ERROR: virtualenv is not compatible with this system or executable
您可以使用'-p'選項指定Anaconda的Python 3解釋器的路徑。 – edwinksl
anaconda的python通常會自動找到,至少在Ubuntu上。當在virtualenv之外時,'python'是否使用anaconda python? –
是的,當它在virtualenv之外時,它使用Python 3.5。但仍然搞清楚如何將其加載到virtualenv ... –