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

1

5

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?

Brock answered 27/4, 2017 at 17:36 Comment(0)
R
7

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.

Revelation answered 27/4, 2017 at 17:38 Comment(1)
mkvirtualenv -p c:\python37\python.exe new_envDuda

© 2022 - 2024 — McMap. All rights reserved.