This PEP proposes to add to Python a mechanism to automatically recognize a __pypackages__ directory and prefer importing packages installed in this location over user or global site-packages. This will avoid the steps to create, activate or deactivate "virtual environments". Python will use the __pypackages__ from the base directory of the script when present.

Python virtual environments have become an essential part of development and teaching workflow in the community, but at the same time, they create a barrier to entry for many. The following are a few of the issues people run into while being introduced to Python (or programming for the first time).

When the Python binary is executed, it attempts to determine its prefix (as stored in sys.prefix ), which is then used to find the standard library and other key files, and by the site module to determine the location of the site-package directories. Currently the prefix is found -- assuming PYTHONHOME is not set -- by first walking up the filesystem tree looking for a marker file ( os.py ) that signifies the presence of the standard library, and if none is found, falling back to the build-time prefix hard coded in the binary. The result of this process is the contents of sys.path - a list of locations that the Python import system will search for modules.

This PEP proposes to add a new step in this process. If a __pypackages__ directory is found in the current working directory, then it will be included in sys.path after the current working directory and just before the system site-packages. This way, if the Python executable starts in the given project directory, it will automatically find all the dependencies inside of __pypackages__ .

In case of Python scripts, Python will try to find __pypackages__ in the same directory as the script. If found (along with the current Python version directory inside), then it will be used, otherwise Python will behave as it does currently.

If any package management tool finds the same __pypackages__ directory in the current working directory, it will install any packages there and also create it if required based on Python version.

Projects that use a source management system can include a __pypackages__ directory (empty or with e.g. a file like .gitignore ). After doing a fresh check out the source code, a tool like pip can be used to install the required dependencies directly into this directory.