Skip to content

Instantly share code, notes, and snippets.

@amineHY
Last active April 9, 2023 13:29
Show Gist options
  • Save amineHY/a806f19a50ac7ac229df76dddc5828ed to your computer and use it in GitHub Desktop.
Save amineHY/a806f19a50ac7ac229df76dddc5828ed to your computer and use it in GitHub Desktop.
Setup python projet using pipenv, do not gorget to make it executable `chmod +x setup_pipenv_env.sh` then run `./setup_pipenv_env.sh`
#!/bin/bash
echo "Checking if pip3 is installed..."
if ! command -v pip3 &> /dev/null
then
echo "pip3 is not installed. Please install it first."
exit 1
else
echo "pip3 is installed."
fi
echo "Checking if pipenv is installed..."
if ! command -v pipenv &> /dev/null
then
echo "pipenv is not installed. Installing pipenv..."
pip3 install pipenv || { echo "Failed to install pipenv"; exit 1; }
else
echo "pipenv is already installed."
fi
echo "Removing existing pipenv environment (if it exists)..."
pipenv --rm || { echo "Failed to remove existing pipenv environment"; exit 1; }
echo "Creating a new environment with Python 3.10.7..."
pipenv --python 3.10.7 || { echo "Failed to create pipenv environment"; exit 1; }
echo "Activating the environment..."
pipenv shell || { echo "Failed to activate pipenv environment"; exit 1; }
echo "Installing required packages..."
pipenv install pandas ipykernel || { echo "Failed to install packages"; exit 1; }
echo "Registering the pipenv environment as a Jupyter kernel with the project name..."
python -m ipykernel install --user --name=$(basename $(pwd)) || { echo "Failed to register kernel"; exit 1; }
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment