Forcing Poetry to Use Python3 on Ubuntu 18.04

Article by Wayne Fagan. Published on 18 Feb, 2020.

Recently the company I work for (Giant Digital) made the decision to move away from Pipenv as the main Python packaging tool to Poetry, as a result I had to install Poetry to work on some of the newer projects.

I found that using the install instructions for Poetry persistently resulted in environments with a Python2.7 dependency.

    python = "^2.7"        

After searching around on Google I came across a frequently recommended install script which was supposed to install Poetry with a Python3 depedency.    

    curl -SSL | python3

This failed to change the Python dependency to Python3.

Next I stumbled across another popular recommendation to modify **~/.poetry/bin/poetry** to.    

    #!/usr/bin/env python3

Notice the change to **python3**

This did not work either.

Finally, the solution I found which actual worked was to add the following alias entry to **.zshrc** and/or **.bashrc**

    alias poetry="python3 $HOME/.poetry/bin/poetry"

This resulted in Python3.7 being set as the dependency.

    python = "^3.7"

At this moment I am unsure as to whether this is an Ubuntu only issue or is persistent across other Debian based distros. That being said I do hope that this article may be of some use to someone else who may be in a similar situation.