Python and venv lookup

Some commands try to find out the best venv to get information about packages or the best python executable to install packages or create venv. There is described lookup order for these commands.

Python interpreter lookup

  1. python parameter in the config (or as CLI argument --python, of course). You can define python here in any way as you want:
    1. Version (3.7)
    2. Exact version (3.7.2)
    3. Constraint (>=3.5)
    4. Executable name (python3)
    5. Path to the executable (/usr/bin/python3)
  2. Dependencies file defined in from parameter. For example, python_requires from
  3. If nothing was found current interpreter (that runs DepHell) will be used.

This lookup is used in commands that can create virtual environment:

Virtual environment (venv) lookup

  1. If virtual environment for current project (can be specified with --config) and environment (can be specified with --env) exists then this virtual environment will be used. This is the reason why you have to create virtual environment before dependencies installation. Can be overwritten by --venv parameter.
  2. If some venv is active then it will be used.

This lookup is used in command dephell inspect venv.

Python environment

Python environment – any python interpreter: virtual environment or globally installed interpreter. This lookup used when DepHell looks for place to work with packages (analyze, install, remove).

  1. First of all, DepHell tries to find virtual environment by virtual environment lookup.
  2. If there is no virtual environment then DepHell looks for best global interpreter by Python interpreter lookup.

Commands that use this lookup:

If you want to force DepHell ignore project venvs and use global interpreter you can pass into command non-existent venv:

$ dephell package install --venv=none homoglyphs
INFO build dependencies graph...
INFO installation... (executable=/usr/local/bin/python3.7, packages=1)