This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vinay.sajip
Recipients Antony.Lee, vinay.sajip
Date 2017-11-21.21:51:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The problem for venv is that it's tied to the running interpreter, which is (in the case you mention) the one from the outer virtualenv. Unlike virtualenv, venv does not provide a mechanism to restart itself with a different Python interpreter.

I don't know how Conda works in detail, but virtualenv makes copies of parts of the stdlib; venv, on the other hand, doesn't, but keeps a reference to its original Python environment. That is, I think, the reason for the difference in behaviour.

Instead of just using 'python' to invoke the command which runs the "-mvenv", you could get the underlying Python and create the venv using that. For example, using this script "":

#!/usr/bin/env python
def make_venv(venvpath):
    import os
    import subprocess
    import sysconfig

    python = os.path.join(sysconfig.get_config_var('BINDIR'), 'python3')
    cmd = [python, '-mvenv', venvpath]

if __name__ == '__main__':
    import sys
    assert len(sys.argv) == 2
        rc = make_venv(sys.argv[1])
    except Exception as e:
        print('Failed: %s' % e)
        rc = 1

I get:

vinay@ubuntu:/tmp$ cd /tmp
vinay@ubuntu:/tmp$ ve15 --version
vinay@ubuntu:/tmp$ ve15 -p python3 outer
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /tmp/outer/bin/python3
Also creating executable in /tmp/outer/bin/python
Installing setuptools, pip, wheel...done.
vinay@ubuntu:/tmp$ source outer/bin/activate
(outer)  vinay@ubuntu:/tmp$ python inner
(outer)  vinay@ubuntu:/tmp$ source inner/bin/activate
(inner)  vinay@ubuntu:/tmp$ python -minspect -d pip
Target: pip
Origin: /tmp/inner/lib/python3.5/site-packages/pip/
Cached: /tmp/inner/lib/python3.5/site-packages/pip/__pycache__/__init__.cpython-35.pyc
Loader: <_frozen_importlib_external.SourceFileLoader object at 0x7f6917e9e860>
Submodule search path: ['/tmp/inner/lib/python3.5/site-packages/pip']

which seems OK.

This approach can't be transplanted into venv because it doesn't have the ability to restart with a different interpreter.
Date User Action Args
2017-11-21 21:51:51vinay.sajipsetrecipients: + vinay.sajip, Antony.Lee
2017-11-21 21:51:51vinay.sajipsetmessageid: <>
2017-11-21 21:51:51vinay.sajiplinkissue30811 messages
2017-11-21 21:51:51vinay.sajipcreate