After using virtualenv for a long time, I found myself in an “entanglement” for my latest project. I’m glad to say I found a better way to manage dependencies. (The commands below were run on Mac)
pyenv
Install py env:
brew install pyenv
For windows please click this link.
Then you can install your desired python version (3.9 at the time of writing). You can also install multiple versions to use in different projects.:
pyenv install 3.9.0
To change your global python version use:
pyenv global 3.9.0
Followed by:
eval "$(pyenv init -)"
This will ensure your default python version is the pyenv version.
Create new directory
mkdir new_project&& cd new_project
Now that we are inside our folder we can simply run:
pyenv local 3.9.0
Now we have ensured that our new_project will be using the desired python version.
pipenv
Install pip env
pip install -U pipenv
Make sure you are in your project directory.
cd new_project
pipenv install
We have now initialized a new project. This process will create a pipfile.lock. If there was a requirements.txt it will move over your packages.
Installing new packages
To install new packages
pipenv install package-name
Installing Jupyter notebook
pipenv install ipykernel
pipenv shell
python -m ipykernel install --user --name=my-virtualenv-name
To start your jupyter notebook
jupyter notebook
Resources
A more Comprehensive breakdown of the two packages can be found here.