我的Python虚拟环境使用virtualenv创建时使用python3.6

~ $ virtualenv my_env

但我需要用python3.5,因为3.6等于not currently supported by Opencv3.

我曾try 在创建虚拟环境时使用--python=<py_version>标志,但这不起作用.

How do I specify the python (3.x) version to install using virtualenv for Mac and/or Linux?

推荐答案

假设您已经安装了python3或任何想要的Python版本(2.6、2.7、3.5、3.6),现在在创建虚拟环境时直接传递Python可执行路径.因此,这里有几个有效的例子

$ virtualenv new_p2_env # Creates a new default python environment (usually python 2)

$ virtualenv -p python3 new_p3_env # Creates a new default python3 (python3 must be a valid command i.e found in the PATH) 

最后呢

# Directly point to any version of python binary, this can be even another virtualenv's bin/python. 
$ virtualenv -p /path/to/any/bin/python new_env 

Python-3.x相关问答推荐

Python gpsd客户端

正则表达式匹配并提取括号前的单词

如何从拼图分区数据集中读取数据到Polar

循环遍历数据框以提取特定值

如何转换Pandas中的数据,以使我 Select 的列名变为行值并增加行?

按长度和字母数字对Pandas 数据帧列进行排序

从.csv导入将文件夹路径加入到文件名

如果集合大于 len(x),则 pandas 在重复的行中拆分集合列

在 pytest 中,如何测试 sys.exit('some error message')?

Python 3 - 给定未知数量的类别动态地将字典嵌套到列表中

正则表达式来识别用 Python 写成单词的数字?

通过 requests 库调用 API 获取访问令牌

命名元组内命名元组的 Python 语法

将字符串表示与使用整数值的枚举相关联?

在 Pandas 数据框中显示对图

Tensorflow:ImportError:libcudnn.so.7:无法打开共享对象文件:没有这样的文件或目录

try 在 Windows 10 高 DPI 显示器上解决模糊的 tkinter 文本 + zoom ,但担心我的方法不是 Pythonic 或不安全

Python 的 unittest 和 unittest2 模块有什么区别?

为什么 Python 不能识别我的 utf-8 编码源文件?

Python 3中星型导入的函数形式是什么