【发布时间】:2017-01-30 12:12:47
【问题描述】:
我已经通过 Anaconda 在 OSX 系统上安装了 Python 3.5。安装并激活虚拟环境后,
virtualenv venv
source venv/bin/activate
Python 版本是 Python 2.7.10。虽然我们可以在virtualenv 中加载我们选择的解释器,但“/usr/bin/”只有 Python 2.6 和 2.7 的文件夹。找出 Anaconda python 3.5 路径后(/Users/Username/anaconda/lib/python3.5) 并尝试加载它,
for: virtualenv -p /Users/Username/anaconda/lib/python3.5 venv
代码返回 [Errno 13] Permission Denied
> 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 解释器的路径。 -
anaconda 的 python 通常会自动找到,至少在 ubuntu 上是这样。在 virtualenv 之外时,
python是否使用 anaconda python? -
是的,在 virtualenv 之外它使用 Python 3.5。但仍在弄清楚如何将其加载到 virtualenv...
-
试试 bin/python3.5 而不是 lib/python3.5 ?
-
谢谢!现在权限错误消失了,但似乎出现了另一个错误,请参阅我更新的问题以获取更多信息
标签: python python-2.7 python-3.x virtualenv