- Setting Up The Environment
- Using Virtual Environments in Jupyter Notebook and Python
- Handling Dependencies, Collaboration and Github
We want to standarize which versions of Python we're running, we can do that using pyenv
.
- Install Homebrew
xcode-select --install
xcode-select -p
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Install Pyenv, a tool that allows you to specify which Python version you want to use:
brew update && brew doctor
brew install pyenv
export PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.0
pyenv install 3.4.4
-
Verify version was installed
pyenv versions
and verify3.4.4
is present in the list -
Configure Bash Profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
-
Set the Python version globally on the system
pyenv global 3.4.4
-
Download VSCode from
https://code.visualstudio.com/
-
Install the
Jupyter
VSCode extension by searching with (⇧⌘P) and typingInstall extension
-
Install NBConvert for debugging purposes
pip3 install nbconvert
Now you're ready to start using VSCode and Jupyter together to debug and build notebooks easily.
A virtual environment is an isolated working copy of Python. This means that each environment can have its own dependencies or even its own Python versions. This is useful if you need different versions of Python or packages for different projects. This also keeps things tidy when testing packages and making sure your main Python installation stays healthy.
Let's setup a new isolated virtual environment for our Jupyter notebook to ensure we don't have library or version conflicts with our dependencies.
- Install virtualenv dependencies (you should only have to run this once forever)
pip3 install virtualenv
- Setup a new virtualenv and install the kernel (you would do this for every project you want to have)
virtualenv jupyterenv
source jupyterenv/bin/activate
pip3 install ipykernel
- Verify you're running within the virtual environment like so:
pip -V
pip install -r reqs.txt