From f867159060fcfc31edf32decb09f55baeb9ed49d Mon Sep 17 00:00:00 2001 From: Declan Gazil Date: Tue, 26 Sep 2023 20:56:35 -0400 Subject: [PATCH 1/5] Added detailed steps on how to create and add your conda environments to jupyter notebook. --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/README.md b/README.md index 3b49e6f3..e62e7cd2 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,52 @@ The standard `git diff` is not particularly useful for `.ipynb` files, especially for computed ones, but the rendered file can be viewed in PR and _nbdiff_ in command line can show a human-readable difference. +### Adding Conda Environment to Jupyter Notebook + + Conda allows you to create isolated environments with specific + versions of Python and its packages. This prevents conflicts between + different projects' dependencies. + + +**Step 1: Create your conda environment.** +Inside of your conda based command line use the following command +`conda create --name firstEnv` +firstEnv is the name of your environment. Change as needed. + + +**Step 2: Activate your environment.** +Using your newly created environment from the previous step, run +`conda activate firstEnv` +Now you have entered into your environment. + + +**Step 3: Install any necessary packages for your environment.** +Now you can install any package you need for your environment. +Below is an example installation for pipenv, a dependency for +popsborder. +`conda install -c conda-forge pipenv` + + +**Step 4: Setting up your conda environment on jupyter notebook.** +Download ipykernel, a Python kernel that allows you to execute +Python code within your botebooks. +`conda install -c anaconda ipykernel` + + +Next Run the following command replacing firstEnv with your +environment name: +`python -m ipykernel install --user --name=firstEnv` +This installs a jupyter kernel in your environment allowing you to +use your kernel in Jupyter Notebook. + + +**Step 5: Open Jupyter Notebook.** +Run from within your environment +`jupyter notebook` +This will open jupyter notebook in your default browser or provide +a url in the terminal. You now have your environment linked to +jupyter notebook. + ## Authors - Vaclav Petras, NCSU Center for Geospatial Analytics From 6e62035a1e7957c31e6fe3fe05b80d597e2d411e Mon Sep 17 00:00:00 2001 From: Declan Gazil Date: Tue, 26 Sep 2023 20:59:39 -0400 Subject: [PATCH 2/5] Fixed typo. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e62e7cd2..7e1160a2 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ The standard `git diff` is not particularly useful for `.ipynb` files, especially for computed ones, but the rendered file can be viewed in PR and _nbdiff_ in command line can show a human-readable difference. -### Adding Conda Environment to Jupyter Notebook +### Adding Conda Environments to Jupyter Notebook Conda allows you to create isolated environments with specific versions of Python and its packages. This prevents conflicts between From 459a43b75332a60c2a4e7518bac1cbd21b6f4d60 Mon Sep 17 00:00:00 2001 From: Declan Gazil Date: Tue, 26 Sep 2023 21:18:20 -0400 Subject: [PATCH 3/5] Fixed spacing. --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 7e1160a2..bfe9e6d6 100644 --- a/README.md +++ b/README.md @@ -131,39 +131,33 @@ and _nbdiff_ in command line can show a human-readable difference. versions of Python and its packages. This prevents conflicts between different projects' dependencies. - **Step 1: Create your conda environment.** Inside of your conda based command line use the following command `conda create --name firstEnv` firstEnv is the name of your environment. Change as needed. - **Step 2: Activate your environment.** Using your newly created environment from the previous step, run `conda activate firstEnv` Now you have entered into your environment. - **Step 3: Install any necessary packages for your environment.** Now you can install any package you need for your environment. Below is an example installation for pipenv, a dependency for popsborder. `conda install -c conda-forge pipenv` - **Step 4: Setting up your conda environment on jupyter notebook.** Download ipykernel, a Python kernel that allows you to execute Python code within your botebooks. `conda install -c anaconda ipykernel` - Next Run the following command replacing firstEnv with your environment name: `python -m ipykernel install --user --name=firstEnv` This installs a jupyter kernel in your environment allowing you to use your kernel in Jupyter Notebook. - **Step 5: Open Jupyter Notebook.** Run from within your environment `jupyter notebook` From 4cc84e2b76765355a82027802996ca4c8674e9df Mon Sep 17 00:00:00 2001 From: Declan Gazil Date: Wed, 27 Sep 2023 18:23:22 -0400 Subject: [PATCH 4/5] Made changes mentioned in pull request comments. Followed conventional header format. Changed steps to h3s. Made the information more specific to PopsBorder. Tested for correctness too --- README.md | 40 --------------------- docs/conda_windows_install.md | 68 +++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index bfe9e6d6..3b49e6f3 100644 --- a/README.md +++ b/README.md @@ -125,46 +125,6 @@ The standard `git diff` is not particularly useful for `.ipynb` files, especially for computed ones, but the rendered file can be viewed in PR and _nbdiff_ in command line can show a human-readable difference. -### Adding Conda Environments to Jupyter Notebook - - Conda allows you to create isolated environments with specific - versions of Python and its packages. This prevents conflicts between - different projects' dependencies. - -**Step 1: Create your conda environment.** -Inside of your conda based command line use the following command -`conda create --name firstEnv` -firstEnv is the name of your environment. Change as needed. - -**Step 2: Activate your environment.** -Using your newly created environment from the previous step, run -`conda activate firstEnv` -Now you have entered into your environment. - -**Step 3: Install any necessary packages for your environment.** -Now you can install any package you need for your environment. -Below is an example installation for pipenv, a dependency for -popsborder. -`conda install -c conda-forge pipenv` - -**Step 4: Setting up your conda environment on jupyter notebook.** -Download ipykernel, a Python kernel that allows you to execute -Python code within your botebooks. -`conda install -c anaconda ipykernel` - -Next Run the following command replacing firstEnv with your -environment name: -`python -m ipykernel install --user --name=firstEnv` -This installs a jupyter kernel in your environment allowing you to -use your kernel in Jupyter Notebook. - -**Step 5: Open Jupyter Notebook.** -Run from within your environment -`jupyter notebook` -This will open jupyter notebook in your default browser or provide -a url in the terminal. You now have your environment linked to -jupyter notebook. - ## Authors - Vaclav Petras, NCSU Center for Geospatial Analytics diff --git a/docs/conda_windows_install.md b/docs/conda_windows_install.md index 3a2cbe92..6c59e472 100644 --- a/docs/conda_windows_install.md +++ b/docs/conda_windows_install.md @@ -17,3 +17,71 @@ conda deactivate ``` To use your environment, run the command "conda activate popsborder_env" or select the popsborder_env environment from your IDE (e.g. VS Code, Atom, PyCharm). + +## Adding Conda Environments to Jupyter Notebook + + Conda allows you to create isolated environments with specific + versions of Python and its packages. This prevents conflicts between + different projects' dependencies. + +### Step 1: Create your conda environment. +Inside of your conda based command line navigate inside your forked PopsBorder +folder. Next use the following command +```bat +conda create -n PopsBorderEnv python=3.8 +``` +This creates your environment with python version 3.8. +PopsBorderEnv is the name of your environment. Change as needed. + +### Step 2: Activate your environment. +Using your newly created environment from the previous step, run +```bat +conda activate PopsBorderEnv +``` +Now you have entered into your environment. + +### Step 3: Install pipenv into you environment. +Now install pipenv into your environment, a packaging tool we utilize +for our project. +```bat +pip install pipenv +``` + +### Step 4: Install dependencies using pipenv. +To download dependencies and create a virtual environment from the Pipfile.lock use: +```bat +pipenv install +``` +Now that your virtual environment is created, navigate into it with +```bat +pipenv shell +``` + +### Step 5: Install your jupyter notebook in your Virtual Environment. +Run the command below to install the necessary python kernel. +```bat +pip install ipykernel +``` +Next Run the following command replacing PopsBorderEnv with your +environment name: +```bat +python -m ipykernel install --user --name=PopsBorderEnv +``` +This installs a jupyter kernel in your environment, allowing you to +use your kernel in Jupyter Notebook. + +### Step 6: Open Jupyter Notebook. +Run from within your environment +```bat +jupyter notebook +``` +This will open jupyter notebook in your default browser or provide +a url in the terminal. You now have your environment linked to +jupyter notebook. + +### Step 7: Select the correct kernel. +Navigate into the notebook file you want to run, denoted by .ipynb. +Examples can be found in the /examples/notebooks folder. +Click on the Kernel tab, then the "Change Kernel" tab and select your +created environment, in this case ours is "PopsBorderEnv". +Now you can run the notebook files. \ No newline at end of file From 5e27096e073aeda9ce77c1ff84f05e93d4ee1962 Mon Sep 17 00:00:00 2001 From: Declan Gazil Date: Wed, 27 Sep 2023 21:53:43 -0400 Subject: [PATCH 5/5] Changed pip statements to conda and reduced statements by adding pipenv run --- docs/conda_windows_install.md | 36 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/docs/conda_windows_install.md b/docs/conda_windows_install.md index 6c59e472..60c2e162 100644 --- a/docs/conda_windows_install.md +++ b/docs/conda_windows_install.md @@ -20,11 +20,11 @@ To use your environment, run the command "conda activate popsborder_env" or sele ## Adding Conda Environments to Jupyter Notebook - Conda allows you to create isolated environments with specific - versions of Python and its packages. This prevents conflicts between - different projects' dependencies. +Conda allows you to create isolated environments with specific versions of Python and its packages. +This prevents conflicts between +different projects' dependencies. -### Step 1: Create your conda environment. +### Step 1: Create your conda environment Inside of your conda based command line navigate inside your forked PopsBorder folder. Next use the following command ```bat @@ -33,55 +33,51 @@ conda create -n PopsBorderEnv python=3.8 This creates your environment with python version 3.8. PopsBorderEnv is the name of your environment. Change as needed. -### Step 2: Activate your environment. +### Step 2: Activate your environment Using your newly created environment from the previous step, run ```bat conda activate PopsBorderEnv ``` Now you have entered into your environment. -### Step 3: Install pipenv into you environment. +### Step 3: Install pipenv into you environment Now install pipenv into your environment, a packaging tool we utilize for our project. ```bat -pip install pipenv +conda install pipenv ``` -### Step 4: Install dependencies using pipenv. -To download dependencies and create a virtual environment from the Pipfile.lock use: +### Step 4: Install dependencies using pipenv +To download dependencies and create a virtual environment from the Pipfile.lock use: ```bat pipenv install ``` -Now that your virtual environment is created, navigate into it with -```bat -pipenv shell -``` -### Step 5: Install your jupyter notebook in your Virtual Environment. +### Step 5: Install your jupyter notebook in your Virtual Environment Run the command below to install the necessary python kernel. ```bat -pip install ipykernel +pipenv run conda install ipykernel ``` Next Run the following command replacing PopsBorderEnv with your environment name: ```bat -python -m ipykernel install --user --name=PopsBorderEnv +pipenv run python -m ipykernel install --user --name=PopsBorderEnv ``` This installs a jupyter kernel in your environment, allowing you to use your kernel in Jupyter Notebook. -### Step 6: Open Jupyter Notebook. +### Step 6: Open Jupyter Notebook Run from within your environment ```bat -jupyter notebook +pipenv run jupyter notebook ``` This will open jupyter notebook in your default browser or provide a url in the terminal. You now have your environment linked to jupyter notebook. -### Step 7: Select the correct kernel. +### Step 7: Select the correct kernel Navigate into the notebook file you want to run, denoted by .ipynb. Examples can be found in the /examples/notebooks folder. -Click on the Kernel tab, then the "Change Kernel" tab and select your +Click on the Kernel tab, then the "Change Kernel" tab and select your created environment, in this case ours is "PopsBorderEnv". Now you can run the notebook files. \ No newline at end of file