Skip to content

Virtual Environment

As mentioned before, Poetry creates an isolted virtual environment to ensure that the project only has access to the dependencies listed in the pyproject.toml file. The virtual environments are created in {cache-dir}/virtualenvs, where {cache-dir} defaults to ~/Library/Caches/pypoetry for macOS and ~/.cache/pypoetry for Unix. Alternatively, you can set a flag so that the virtual environment is created in the project folder as ./venv, using:

Text Only
poetry config virtualenvs.in-project true

To enter this virtual environment, so that you can use all the installed tools, run:

Text Only
poetry shell

From there, you can access all installed packages, scripts, etc., regularly in the terminal.

However, if you'd like to stay outside of the shell, but still run all of Poetry's tools installed in virtual environment, you can prepend the command

Text Only
poetry run <command>

before every command. The rest of these guidelines will assume you're in the shell, but if not, make sure to prepend the above.