If you are on Windows and have to work with an Ubuntu project you'll need to use Windows Subsystem for Linux. This tutorial will guide you to set up pyenv and poetry semi-automatically. It assumes you already installed VSCode and Git Bash and have your project locally available.
In order to download Windows Subsystem for Linux, do the following:
- Open powershell in adm mode;
- Type and run
wsl --install -d Ubuntu
; - Once installed, choose login and password for the sub-system;
Now you will have to connect WSL-Ubuntu to VSCode:
- Install the Remote Development in your VSCode, by using VSCode's Extensions;
- Go into your project folder, and on the path (top part of the window), type:
powershell
; - In the shell window type
wsl
(notice the shell changes); - Type
code .
(the VS Code Server will be installed the first time you run this);
In this moment your WSL-Ubuntu is correctly connected to VSCode (notice the message at the bottom left green box). Now you need to configure the Ubuntu for your project (that is, installing python, pyenv and poetry). Luckly you don't need to do it by hand, since there are some shell scripts that do the job for you.
- Put the shell scripts in you project's folder;
- Change the selected end of line sequence in VSCode to 'LF' so the shell file will be executed correctly;
- Run the pyenv instalation script by running
./install_pyenv.sh
(this installs pyenv for you). - Once the
install_pyenv.sh
script stops, runpyenv install 3.9.10
; - Make your python version global by running
pyenv global 3.9.10
; - Close the terminal and run the poetry installation script
./install_poetry.sh
(this installs poetry for you);
Now you just need to install/create your poetry project:
- After closing the previous shell and opening another one, run
install_project.sh
. If you prefer, you can iteratively create a brand-new, fresh project withcreate_default_project.sh
.
OBS: In case you are not happy with the software and decide to try something different, and it is necessary to uninstall poetry and pyenv, you can do the following:
- To uninstall poetry, run in your terminal:
curl -sSL https://install.python-poetry.org | python - --uninstall
. You will need to removeexport PATH="$HOME/.local/bin:$PATH"
from your .bashrc file also; - To uninstall pyenv, follow the documentation steps for uninstalling. In case you need to modify a text file using shell, open it using vi and, once modified, write and quit using
:wq
. You can check if the text file was modified usingcat
.
Happy coding! ;)