Shell files capable of automating the creation of data science projects. Some tutorials are provided.
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
. - find out the recently installed packages;
- list all installed packages
- how to uninstall packages installed in a certain time range
Happy coding! ;)
- Make sure you have
curl
installed in your machine before running the first script. In case you don't have it, you can install usingsudo apt install curl
; - Make sure you have
git
installed in your machine before running the first script. Actually, in a Ubuntu machine you don't have to install Git Bash. Installing git only is enough. Here is some guide on installing git on Ubuntu; - Once pyenv is installed, it was necessary to install Tkinter in order to install Python using pyenv. Following PaulMest answer to this StackOverFlow question, you must run:
$ sudo apt-get install python-tk python3-tk tk-dev
. - Once pyenv is installed, it may be more comfortable to have pyenv to load automatically. At the end, it means it won't be [encher teu terminal de comando] everytime you open it. To do so, you must append the following lines to
~/.bash_profile
if it exists, or to~/.profile
:
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"