Repository navigation
Home
tameen edited this page May 25, 2023
·
2 revisions
- It is a new Python Package manager.
- It combines Virtualenv and pip.
- It can create python virtual environment.
- It can manage python project dependencies.
- It is faster than pipenv and more reliable tool than pipenv.
- sudo apt install curl
- curl -sSL https://install.python-poetry.org | python3 – Open bashrc file (vim ~/.bashrc) and add export PATH = $PATH:$HOME/.local/bin
Virtual environment is a copy of your python installation. Any python package manager install all packages for that particular python installation. It’s better to set up a directory where poetry set up python and its packages.
- poetry –v
- poetry config –list
To change the directory where poetry stores virtual environment ~/.cache/pypoetry/virtualenvs run the command
- poetry config virtualenvs.in-project true
- poetry init
- poetry init –n
It will create a file pyproject.toml which will carry all dependencies (Production and Execution)
- poetry new new_project
- poetry add django (Automatically created and generated a virtual environment for project and istall all te dependencies)
Create new file main.py for project and write:
from django import VERSION
print (Version)
- python main.py (Error: Unknown django )
- poetry run python main.py (No Error since poetry added all dependencies)
- poetry shell
- python main.py
- python –i main.py
- poetry show –tree
- poetry remove django