Page cover

Virtual Environments

Last updated Jan 16, 2025

My first error in the course was solved due to a virtual environment issue. So let's talk about setting up a virtual environment, specifically conda on a Mac.

I will add that it is my understanding that a new virtual environment is encouraged for each module - though there may be one module that does not need one? I will update this page once I know the answer!

[Optional] Brew install iterm2

It was recommended to me to use iterm2

  1. Do you have homebrew installed?

    1. Open a terminal window and type

brew

b. If yes, continue. If no, installl homebrew - details https://docs.brew.sh/Installation

  1. brew install iterm2

Conda

  1. You may need to install Anaconda, so head over to the site if you do not have the application.

  2. Open iterm2 (a terminal window) and type

python -V

This will show your python version for your awareness

  1. Now the fun part, create an environment! Remember, we will want a different environment for each project. I am using python version 3.12, so the command is

conda create -n myenvname python=3.12
  1. Now we want to add our packages that are not included in the standard library, such as pandas. To do that, we need to activate the environment and then pip install what we need.

conda activate myenvname

In your terminal, your myenvname of choice should now show at the far left of your command promt in parentheses like

(myenvname) Kaylas-MacBook-Air:data-engineering-zoomcamp-my-work kayla$

pip install pandas sqlalchemy psycopg2-binary jupyterlab

In the future, to use these packages, we import them into our python scripts. For example, for pandas we would write import pandas as pd at the top of our python script.

Briefly discussed w/ course instructur but not used

Last updated