Skip to content

Instantly share code, notes, and snippets.

@odoku
Last active February 28, 2020 05:04
Show Gist options
  • Save odoku/80c131ef26e1d537847114611570c4e2 to your computer and use it in GitHub Desktop.
Save odoku/80c131ef26e1d537847114611570c4e2 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eu
# Install PyEnv
if [ ! -e ~/.pyenv ]; then
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
fi
# Install virtualenv
set +e
virtualenv --version 2>&1 | grep 16.7.10 > /dev/null
RESULT=$?
set -e
if [ $RESULT -ne 0 ]; then
pip install -U virtualenv==16.7.10
fi
# Install Pipenv
set +e
which pipenv > /dev/null
RESULT=$?
set -e
if [ $RESULT -ne 0 ]; then
pip install pipenv
fi
cat << EOS
Start Pipenv
pipenv --python
Install modules
pipenv install PyYAML
pipenv install # Install with Pipfile
pipenv install -r requirement.txt # Install with requirement.txt
pipenv install --dev flake8 # For development
Uninstall modules
pipenv uninstall PyYAML
pipenv uninstall --dev flake8
Start virtual environment
pipenv shell
Exit virtual environment
exit (or ctrl+d)
Remove virtual environment
pipenv --rm
EOS
@odoku
Copy link
Author

odoku commented Feb 28, 2020

curl -L https://gist.githubusercontent.com/odoku/80c131ef26e1d537847114611570c4e2/raw/81728c218d924a1e612d3a6fbbbf8e7ceb70c050/setup_pipenv.sh | bash
source ~/.bash_profile
pyenv -v
pipenv --version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment