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

扶醉桌前 提交于 2019-12-24 06:33:08

问题


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

OK so far.

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

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

Where'd this come from?

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


回答1:


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

mkvirtualenv -p `which python` foo

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



来源:https://stackoverflow.com/questions/43664467/how-can-i-tell-mkvirtualenv-which-version-of-python-id-like-to-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!