I needed python3.7 for a project and it wasn't available as a ubuntu package, so I bootstrapped a python3.7 environment using conda. From that 'grandparent' environment, I created a 'parent' python3 virtual environment for the specific project.
From the parent environment in my project, I'm running a command line tool from the google-cloud-sdk which creates another test environment. That script creates a 'grandchild' environment by calling something equivalent to (parent) $ python3 -m venv /tmp/grandchild
.
That grandchild environment doesn't have the pip binary installed, for some reason or another. And this is the problem. This missing pip causes the google script to fail to install dev-test dependencies. The parent, and the child do have pip installed, however, but pip doesn't get passed down.
When I take conda out of the picture, and rely only on the python that ships with my ubuntu package system (under /usr/lib), I can nest my virtual environments ad nauseam, and pip always seems to get inherited properly. I think this is something specific to python/pip conda environments that I'm tripping on.
I think this is a separate cause problem to this: pip missing from Python venv (I don't have that file ~/.pydistutils.cfg anywhere on my box)
UPDATE:
I've found a way to reliably repro this, and without the need for conda. This happens when the parent is created with virtualenv, i.e. virtualenv parent
, and the child gets created from that parent using -m venv
, i.e. (parent) $ python3 -m venv child
. The child then doesn't get pip copied into it.
Nesting environments created with virtualenv
works fine, and nesting environments created with venv
works well too, but not when venv is used within a virtualenv-created environnment. They don't mix.
Note: environments don't really "nest" per-se, they are independent copies. I mean that one is created from the other.