Install pyenv
to manage Python versions, install Python and set the global version to use.
brew install pyenv
# install python 3.9.4
pyenv install 3.9.4
# set global version of python
pyenv global 3.9.4
If you're using MacOS and zsh
, then run this too:
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc
echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.zshrc
For Bash:
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.bash_profile
echo 'PATH=$(python -m site --user-base)/bin:$PATH' >> ~/.bash_profile
You might need to also alias pip
to pip3
:
echo 'alias pip=/opt/homebrew/bin/pip3' >> ~/.zshrc
For Bash:
echo 'alias pip=/opt/homebrew/bin/pip3' >> ~/.bashrc
pip install pipenv
Set PIPENV_VENV_IN_PROJECT='enabled'
to create .ven
at the root level instead of at the user level.
export PIPENV_VENV_IN_PROJECT='enabled'
pipenv runt test
Install packages via pipenv
. The PIPENV_VENV_IN_PROJECT
set above will tell pipenv
to install packages in the .venv
folder at the root level of this codebase. This encourages reproducible builds.
pipenv install <package>