Vinay Sajip <vinay_sa...@yahoo.co.uk> added the comment: 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 "upvenv.py": #!/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] subprocess.run(cmd) if __name__ == '__main__': import sys assert len(sys.argv) == 2 try: rc = make_venv(sys.argv[1]) except Exception as e: print('Failed: %s' % e) rc = 1 sys.exit(rc) I get: vinay@ubuntu:/tmp$ cd /tmp vinay@ubuntu:/tmp$ ve15 --version 15.1.0 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 upvenv.py 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/__init__.py 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue30811> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com