Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unfortunately, it is not possible to create a new virtualenv within a subdirectory of an existing virtualenv using pipenv. Each pipenv virtual environment is completely independent of any other virtual environment, and they cannot be nested within each other.

If you want to create a new virtualenv within a subdirectory, you would need to first exit the current virtualenv, create a new virtualenv in the desired subdirectory, and then activate that virtualenv.

Here are the steps to create a new virtualenv within a subdirectory using pipenv:

  1. Navigate to the root directory of your project where your existing virtualenv is located.

  2. Deactivate the current virtualenv if it is currently activated.

pipenv shell
deactivate
  1. Navigate to the subdirectory where you want to create the new virtualenv.
cd subdirectory
  1. Create a new virtualenv using pipenv.
pipenv install
  1. Activate the new virtualenv.
pipenv shell

Now, any packages installed or scripts run within this subdirectory will use the new virtualenv. However, you cannot access or use anything installed in the root virtualenv from within this subdirectory.