Move in "/content"
import os
os.chdir("/content")
Setup git email and username
!git config --global user.email <"Your Email">
!git config --global user.name <"Your Username">
Clone the project from git
!git clone https://<token>@github.com/<Github Username>/<Repository Name>.git
Install poetry from pip
!pip install poetry
Move in the project folder (created after cloning the repository from git)
import os
os.chdir("/content/<Repository Name>")
Configure poetry not to create virtual environments in the project folder
!poetry config virtualenvs.in-project false
Install all dependencies and eventually add extra dependencies
!poetry install
# !poetry run pip install <Extra Dependency Name>
Add poetry virtual environment to python path so that all installed dependencies can be found by the python interpreter
import sys
sys.path.append("/root/.cache/pypoetry/virtualenvs/<Virtual Environment Name>/lib/<Python Version>/site-packages")
Move in the project folder and run the project
import os
os.chdir("/content/<Repository Name>")
!poetry run python <Path to main.py> <Arguments>
Hi @elise-chin-adway,
I have encountered the same issue with poetry on Colab.
Running
poetry install --no-ansi
, as suggested in python-poetry/poetry#7184, worked for me.