最佳答案
使用虚拟环境,我使用默认版本的Python(2.7)运行我的项目。在一个项目中,我需要使用Python 3.4。
我使用brew install python3
在我的Mac上安装它。现在,我如何创建一个使用新版本的虚拟环境?
例如sudo虚拟envPython3
如果我尝试:
virtualenv -p python3 test
我得到:
Running virtualenv with interpreter /usr/local/bin/python3Using base prefix '/usr/local/Cellar/python3/3.4.0_1/Frameworks/Python.framework/Versions/3.4'New python executable in test/bin/python3.4Also creating executable in test/bin/pythonFailed to import the site moduleTraceback (most recent call last):File "/Users/user/Documents/workspace/test/test/bin/../lib/python3.4/site.py", line 67, in <module>import osFile "/Users/user/Documents/workspace/test/test/bin/../lib/python3.4/os.py", line 634, in <module>from _collections_abc import MutableMappingImportError: No module named '_collections_abc'ERROR: The executable test/bin/python3.4 is not functioningERROR: It thinks sys.prefix is '/Users/user/Documents/workspace/test' (should be '/Users/user/Documents/workspace/test/test')ERROR: virtualenv is not compatible with this system or executable