poetry shell

 Basic usage | Documentation | Poetry - Python dependency management and packaging made easy (python-poetry.org)

Activating the virtual environment

The easiest way to activate the virtual environment is to create a new shell with poetry shell. To deactivate the virtual environment and exit this new shell type exit. To deactivate the virtual environment without leaving the shell use deactivate.

Why a new shell?

Child processes inherit their environment from their parents, but do not share them. As such, any modifications made by a child process, is not persisted after the child process exits. A Python application (Poetry), being a child process, cannot modify the environment of the shell that it has been called from such that an activated virtual environment remains active after the Poetry command has completed execution.

Therefore, Poetry has to create a sub-shell with the virtual envrionment activated in order for the subsequent commands to run from within the virtual environment.

Alternatively, to avoid creating a new shell, you can manually activate the virtual environment by running source {path_to_venv}/bin/activate (source {path_to_venv}\Scripts\activate.bat on Windows). To get the path to your virtual environment run poetry env info --path. You can also combine these into a nice one-liner, source $(poetry env info --path)/bin/activate To deactivate this virtual environment simply use deactivate.

POSIX SHELLWINDOWSEXIT/DEACTIVATE
New Shellpoetry shellpoetry shellexit
Manual Activationsource {path_to_venv}/bin/activatesource {path_to_venv}\Scripts\activate.batdeactivate
One-linersource`poetry env info --path`/bin/activatedeactivate

Không có nhận xét nào:

Cold Turkey Blocker

 https://superuser.com/questions/1366153/how-to-get-rid-of-cold-turkey-website-blocker-get-around-the-block Very old question, but still wan...