(Part 3 of series Blueprint for a Modern Research Computing Environment)
Follow me :
This article creates an isolated Conda environment (env_project1), installs numpy through it, and explains when to use conda install vs pip install. You’ll then run the same piece of Python code two ways — as a .py script and inside a JupyterLab .ipynb notebook — to see how the two workflows differ.
In Part 2, we created ~/project_1 — a folder for our first project. But a folder alone is not enough. Every Python project also needs its own environment — a controlled space where you install only the packages that project needs.
In this article, we’ll create that environment, install packages, and run our first Python code in both a .py and .ipynb file.
By the end, you’ll have:
env_project1.py script and a .ipynb notebookAI tools (like Claude, Grok, Gemini, or ChatGPT) give the best troubleshooting advice when they have the exact text of the tutorial. To ensure the AI understands what you are trying to build, we will give it the actual file.
1. Download the tutorial file
2. Upload it to your AI
Part3.md into the chat).3. Ask for Help Copy and paste this exact prompt into the chat along with your file:
I have attached the markdown file for the tutorial I am following. Please read it so you understand the specific environment I am trying to build.
I need help with the following:
Step [X]: [paste exact step text from the blog]
Command I ran: [paste exact command]
What happened: [paste full output/error — if the terminal was truly blank, say so explicitly]
Please help me troubleshoot and fix this error. You can use your general knowledge to solve the problem, but your solution MUST align with the architecture and tools taught in the attached file. Do not suggest alternative setups that contradict the tutorial. Once fixed, tell me what to do next in the article.
To go deeper on a step before you run a command:
I have attached the
Part3.mdfile. Look at Step [X] and explain exactly what the command does and why we are doing it before I run it.
Think of this series as the roadmap and your AI assistant as your learning companion.
Python by itself is minimal. Packages are collections of code written by others that you can use in your own projects.
For example:
numpy — numerical computingpandas — data analysismatplotlib — plottingscikit-learn — machine learningInstead of writing everything from scratch, you install a package and use it.
Imagine two projects:
If you install both on the same Python, they conflict. Virtual environments solve this — each project gets its own isolated Python with its own packages and versions.
With Miniconda, these are called Conda environments.
Navigate to your project folder:
cd ~/project_1
Create an environment named env_project1 with Python 3.11:
conda create -n env_project1 python=3.11 pip
Note: Always include
pipexplicitly when creating an environment. Unlike the defaults channel, conda-forge doesn’t bundle pip automatically with Python — skip it, and laterpip installcommands will fail with errors likepip3: command not foundorNo module named pip.
Conda will show a list of packages to install. Type y and press Enter.
Activate the environment:
conda activate env_project1
Your prompt will change from (base) to (env_project1):
(env_project1) abhigyan@DESKTOP-XXXX:~/project_1$
This means you are now inside your isolated environment. Any package you install from this point goes into env_project1 only — not into any other environment.
Before we install anything, a few commands worth knowing now that you have your first environment.
List all environments:
conda env list
Output:
# conda environments:
#
base * ~/miniconda3
env_project1 ~/miniconda3/envs/env_project1
The * shows your currently active environment.
Where environments are stored:
Each environment lives inside ~/miniconda3/envs/. You never need to go there directly — Conda manages it for you. But knowing this helps when you’re wondering where your packages actually live.
Deactivate an environment:
conda deactivate
Switches you back to (base). Always deactivate before deleting an environment.
Delete an environment:
conda env remove -n env_project1
This permanently deletes the environment and all packages inside it. Don’t run this now — we’ll need env_project1 for the rest of the series.
Make sure env_project1 is active before installing anything:
conda activate env_project1
conda install vs pip installThere are two ways to install packages:
conda install |
pip install |
|
|---|---|---|
| Source | Conda repositories | Python Package Index (PyPI) |
| Handles non-Python dependencies | Yes | No |
| Environment safety | Better | Can break Conda environments if overused |
| When to use | Default choice | When package is not available via Conda |
Rule of thumb: always try conda install first. Use pip install only if the package is not available through Conda.
conda-forge ChannelConda packages are hosted in channels — think of them as app stores. The default Conda channel has many packages, but conda-forge is a community-maintained channel with significantly more packages and more up-to-date versions.
Set conda-forge as your default channel:
conda config --add channels conda-forge
conda config --set channel_priority strict
You only need to do this once — it applies to all environments.
NumPy is a Python package that provides support for arrays and mathematical operations. It is one of the core libraries used in data science and scientific computing.
conda install numpy
Type y when prompted.
Verify the installation:
python -c "import numpy; print(numpy.__version__)"
You should see a version number printed.
.py and .ipynbBefore writing any code, it helps to understand the two file types you’ll use throughout this series.
.py — Python ScriptA plain text file containing Python code. You run it from the terminal and it executes top to bottom.
Best for:
.ipynb — Jupyter NotebookA notebook file where code, output, and text live together in cells. You run cells one at a time and see the output immediately below each cell.
Best for:
Both are valid. Most research workflows use both — notebooks for exploration, scripts for automation.
.py ScriptMake sure you are in ~/project_1 with env_project1 active.
Create a file:
touch first_script.py
Open it in a terminal text editor. We’ll use nano — a simple terminal text editor — to write our script directly in the terminal. (More about nano in Part 5).
nano first_script.py
Type this code:
import numpy as np
a = np.array([1, 2, 3, 4, 5])
print("Array:", a)
print("Mean:", np.mean(a))
print("Sum:", np.sum(a))
Save and exit: press Ctrl+X, then Y, then Enter.
Run the script:
python first_script.py
Expected output:
Array: [1 2 3 4 5]
Mean: 3.0
Sum: 15
Jupyter Notebook is the original browser-based interface for .ipynb files. You write code in cells, run them one at a time, and see output immediately below.
JupyterLab is the modern replacement. It has the same notebook functionality but adds a file browser, terminal, text editor, and multiple tabs — all in one browser window.
For this series, we use JupyterLab.
ipykernel is what connects your Conda environment to JupyterLab. Without it, JupyterLab won’t see env_project1 as an available kernel.
Install both:
conda install jupyterlab ipykernel
Type y when prompted.
Register your environment as a Jupyter kernel:
python -m ipykernel install --user --name env_project1 --display-name "Python (env_project1)"
.ipynb NotebookLaunch JupyterLab:
jupyter lab
JupyterLab will open in your browser automatically. If it doesn’t, copy the URL from the terminal — it will look like:
http://localhost:8888/lab?token= ...... copy the entire line
and paste it into your browser.
In JupyterLab:
import numpy as np
a = np.array([1, 2, 3, 4, 5])
print("Array:", a)
print("Mean:", np.mean(a))
print("Sum:", np.sum(a))
Shift+Enter to run the cellExpected output:
Array: [1 2 3 4 5]
Mean: 3.0
Sum: 15
Same result as the .py script — but this time inside a notebook cell, with output directly below your code.
To stop JupyterLab, go back to the terminal and press Ctrl+C.
JupyterLab is a capable environment. For notebooks and interactive work, it works well on its own.
But as your projects grow, you’ll find yourself needing more:
.py and .ipynb in one place — switch between scripts and notebooks seamlesslyJupyterLab is purpose-built for notebooks and interactive computing — and it does that extremely well. An IDE like VS Code goes further by bringing your entire development workflow — code, terminal, Git, debugger, and notebooks — into a single environment. As your projects grow in complexity, having everything in one place makes a real difference.
In Part 4, we’ll set up VS Code and connect it to the environment we built here.
What You’ve Done:
env_project1conda install vs pip install and set up conda-forge.py and .ipynbNext: Part 4 — Setting Up VS Code | Previous: Part 2 — Terminal Basics and File Navigation