Conda is a command-line tool for managing packages and environments. In TM351, it is used to set up an environment that allows experimentation with Jupyter Notebooks.
Miniforge is an open-source Conda installer. Click Here to Download. Follow instructions to install into your OS. Now you can run Conda via the Miniforge prompt in the Start menu on Windows, or via conda
command on Mac & Linux.
Clone or download this repository.
git clone https://github.com/amkige/tm351-conda.git
-
Run Conda using the Miniforge prompt from the Start menu on Windows, or via
conda
command on Mac and Linux. Ensure (base) appears in the command prompt, indicating the base environment is active like so:(base)>
-
Update base packages
conda update -n base -c conda-forge conda
-
Navigate to the
tm351-conda
directorycd tm351-conda
-
Create
tm351
environment from theenvironment-win.yml
orenvironment-unix.yml
file for windows or Mac/Linux respectively.# Windows conda env create -f environment-win.yml # Mac & Linux conda env create -f environment-unix.yml
-
Activate
tm351
environmentconda activate tm351
-
Ensure
tm351
environment is activeconda activate tm351
-
Initialize a database cluster (Note this will create pg_cluster directory to store data)
initdb -D pg_cluster
-
Start the server
pg_ctl -D pg_cluster -l pg_logs start
-
Create a user and set a password (set the password to dbpass)
createuser --pwprompt dbuser
-
Create a database
createdb --owner=dbuser tm351db
-
Ensure
tm351
environment is activeconda activate tm351
-
Create a directory to store database data
mkdir monogodb_data
-
Start the server
mongod --dbpath monogodb_data --fork --logpath mongodb_logs
-
Import Accidents Database
mongorestore --drop --gzip --archive=./accidents_database.gz
jupyter lab --notebook-dir=./Notebooks
Note
Start the PostgreSQL or MongoDB server before running notebooks that require them
# PostgreSQL
pg_ctl -D pg_cluster -l pg_log start
# MongoDB
mongod --dbpath monogodb_data --fork --logpath mongodb_logs
Stop the servers after finishing
# PostgreSQL
pg_ctl -D pg_cluster stop
# MongoDB
mongod --dbpath monogodb_data --shutdown