gpt4 book ai didi

python - 在 virtualenv 中使用 Python 3

转载 作者:IT老高 更新时间:2023-10-28 11:59:46 29 4
gpt4 key购买 nike

使用 virtualenv ,我使用默认版本的 Python (2.7) 运行我的项目。在一个项目中,我需要使用 Python 3.4。

我使用 brew install python3 在我的 Mac 上安装它。现在,如何创建使用新版本的 virtualenv?

例如sudo virtualenv envPython3

如果我尝试:

virtualenv -p python3 test

我明白了:

Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.4.0_1/Frameworks/Python.framework/Versions/3.4'
New python executable in test/bin/python3.4
Also creating executable in test/bin/python
Failed to import the site module
Traceback (most recent call last):
File "/Users/user/Documents/workspace/test/test/bin/../lib/python3.4/site.py", line 67, in <module>
import os
File "/Users/user/Documents/workspace/test/test/bin/../lib/python3.4/os.py", line 634, in <module>
from _collections_abc import MutableMapping
ImportError: No module named '_collections_abc'
ERROR: The executable test/bin/python3.4 is not functioning
ERROR: 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

最佳答案

简单地运行

virtualenv -p python3 envname

OP 编辑​​后更新:

here 所述,OP 的 virtualenv 版本中存在错误。 .问题已通过运行解决:

pip install --upgrade virtualenv

关于python - 在 virtualenv 中使用 Python 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23842713/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com