我如何告诉 mkvirtualenv 我想使用哪个版本的 Python? [英] How can I tell mkvirtualenv which version of Python I'd like to use?

查看:55
本文介绍了我如何告诉 mkvirtualenv 我想使用哪个版本的 Python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对使用 mkvirtualenv 时安装的 Python 版本感到困惑.在任何 virtualenv 之外,这就是我所拥有的.

I'm puzzled over the version of Python the gets installed when using mkvirtualenv. Outside of any virtualenv here's what I have.

$ which python 
/opt/local/bin/python    << MacPorts installed Python
$ python -V
Python 2.7.13
$ python -c "import ssl; print ssl.OPENSSL_VERSION"
OpenSSL 1.0.2k  26 Jan 2017

到此为止.

现在,制作 virtualenv...

Now, make virtualenv...

$ mkvirtualenv foo
[normal stuff here]
(foo) $ which python
/Users/me/Workspace/venvs/foo/bin/python
(foo)$ python -V
Python 2.7.10

为什么这是python 2.7.10?而不是 python 2.7.13?

Why is this python 2.7.10? and not python 2.7.13?

$ python -c "import ssl; print ssl.OPENSSL_VERSION"
OpenSSL 0.9.8zh 14 Jan 2016

这是从哪里来的?

如何告诉 mkvirtualenv 我想使用哪个版本的 Python?

How can I tell mkvirtualenv which version of Python I'd like to use?

推荐答案

使用 -p(或 --python 选项)指定 python 可执行路径:

Use -p (or --python option) to specify python executable path:

mkvirtualenv -p `which python` foo

确切地说,它是 virtualenv 选项.mkvirtualenv 将未知选项传递给 virtualenv 直接.

To be exact, it's virtualenv option. mkvirtualenv passes unknown options to virtualenv directly.

这篇关于我如何告诉 mkvirtualenv 我想使用哪个版本的 Python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆