self update
poetry self update <version>
Initialize your environment
poetry new <your-project>
cd <your-project>
poetry init
Install packages that are listed on pyproject.toml
If you want to install the dependencies only
poetry install --no-root
Add or Remove Packages
poetry add numpy
poetry add "numpy>=1.19.1"
poetry remove numpy
Show Packages List
poetry show
Execute Commands in a Virtual Environment
poetry run python3 main.py
List up configurations
poetry config --list
cache-dir = "/path/to/cache/directory"
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = true
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs" # /path/to/cache/directory/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
Useful Configuration – to create a virtual environment in own directory
poetry config virtualenvs.in-project true
Useful Configuration – to use a specific python version
poetry config virtualenvs.prefer-active-python true
poetry env use /full/path/to/python
Installation on Dockerfile
RUN apt-get install -y curl
ENV POETRY_HOME=/opt/poetry
RUN curl -sSL https://install.python-poetry.org/ | python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false
RUN poetry install --no-root
CMD ["python", "./main.py"]