Activating virtual environment
Poetry creates its own virtual environment at the time of installation so that it won’t mess with other programs in your system. You can use it as a virtual environment which will be present in your project directory {cache-dir}/virtualenvs}. To activate the virtual environment in your project you simply need to type this command :
poetry shell
This will create a new shell environment if you don’t want that you can simply activate it on your own terminal using the following command :
For Linux
source {path_to_venv}/bin/activate
For Windows
source {path_to_venv}\Scripts\activate.bat
To deactivate the virtual environment you can use a command.
exit
Starting a new Project :
To create a new project you can use the following command:
poetry new new-project
This will create a new project with the name new project you can name it as you want. This will create a new directory with the name new project and the directory structure inside the new project will be like this:
The project structure is like this.
- pyproject.toml: It is the most important file that contains project metadata and other information like project dependencies and developer dependencies with their versions. As we add new dependencies to our project it gets added here. This file should not be edited explicitly.
- README.rst: It is a file that can be edited by the project admin and should contain information about what is this project and how to use it .etc.
- tests: folder contains unit tests related to different units/functions of the program.
- The project folder contains another folder with the same name as the parent directory which contains code files of the program.
Using Poetry Dependency Management tool in Python
In this article, we are going to study the poetry dependency management tool in python which will help you to manage the libraries of your next project so it will be easy to download, install, and set up your project.
Contact Us