🐍
Python Environment
Cleanup & Setup Guide
Step-by-step instructions for a beginner-friendly, clean Miniconda setup on Windows
Includes: Backup → Clean → Create Environments → Bind IDEs → Remove Junk
📌 Before You Begin — Read This First
This guide assumes you have Miniconda installed at D:\miniconda3 (as in your current setup).
You will be using the Anaconda Prompt (NOT Windows PowerShell or CMD) for all commands.
To open Anaconda Prompt: Press Windows key → type Anaconda Prompt → click to open.
Copy-paste each command exactly as written. Do not retype by hand.
Complete every phase in order. Do not skip ahead.
❗ What Is Wrong With Your Current Setup
1. PATH Pollution — Multiple duplicate Miniconda entries and IDE paths in Windows PATH.
2. Python Confusion — Different IDEs use different Python versions without you knowing.
3. No Isolation — All work is done in the base environment (dangerous — base should stay
clean).
4. Package Clutter — Packages installed everywhere with no clear purpose.
5. IDE Chaos — Multiple IDEs pointing to random interpreters automatically.
🎯 What We Are Building
✅ Clean PATH — only essential Miniconda entries remain.
✅ 3 separate environments: research_env | trading_env | ai_env
✅ Base environment stays empty — used only to create/manage other envs.
✅ Spyder settings saved and restored after cleanup.
✅ Every IDE explicitly knows which Python interpreter to use.
✅ Packages removed cleanly with a safety checklist.
STEP
Backup Everything First
0 Never clean anything before creating a safety net
Python Environment Cleanup Guide | Confidential | Page 1 of 14
0a — Back Up All Conda Environments
Open Anaconda Prompt and run the following commands one by one. Each exports a description of an
environment to a file you can restore later.
# First — see what environments you currently have
conda env list
# Export EACH environment you see listed above
# Replace myenv with the actual name shown (repeat for all envs)
conda activate base
conda env export > D:\backups\backup_base.yml
conda activate myenv
conda env export > D:\backups\backup_myenv.yml
💡 How to create the backups folder
Open File Explorer → go to D:\ → right-click → New → Folder → name it backups
This folder will store all your .yml backup files safely.
0b — Back Up Your Spyder Settings
Spyder stores your preferences (themes, shortcuts, code style settings) in a special folder. We will copy
that entire folder to your backup location.
# Step 1: Open File Explorer and navigate to:
C:\Users\YourName\.spyder-py3
# (Replace YourName with your actual Windows username)
# Step 2: Right-click the .spyder-py3 folder → Copy
# Step 3: Go to D:\backups\ → Paste
# You should now have: D:\backups\.spyder-py3
⚠️ Important — Hidden Folders
The .spyder-py3 folder starts with a dot, which means Windows hides it by default.
To see it: Open File Explorer → View tab → tick Hidden items checkbox.
Then you will see the folder and can copy it.
0c — Save a List of All Installed Packages
This gives you a plain-text record of every package across every environment. Useful to cross-check
later.
# Run this for each environment you have
conda activate base
pip list > D:\backups\packages_base.txt
Python Environment Cleanup Guide | Confidential | Page 2 of 14
conda activate trading_env
pip list > D:\backups\packages_trading.txt
# Repeat for any other environments
STEP
Clean Up Windows PATH
1 Remove duplicate and junk entries that confuse Python
What is PATH?
PATH is a Windows setting that tells your computer where to look for programs when you type a
command. When you have 5 IDEs installed, each one adds itself to PATH — and they can conflict with
each other.
1a — View Your Current PATH
Open Anaconda Prompt and run:
# This shows every entry in your system PATH, one per line
echo %PATH:;=&echo.%
Look for any of these problems:
• Multiple lines containing miniconda3 (e.g., D:\miniconda3 AND D:\miniconda3\Scripts
appearing twice)
• Entries for old PyCharm versions (e.g., PyCharm 2022 and PyCharm 2023 both listed)
• Entries for C:\Python39 or C:\Python310 (old standalone Python installs)
1b — Open System PATH Editor
Follow these steps carefully:
1. Press the Windows key on your keyboard
2. Type: environment variables and press Enter
3. Click: Edit the system environment variables
4. Click the Environment Variables button at the bottom
5. In the UPPER section (User variables), find Path → click it → click Edit
6. You will see a list of entries. Select any duplicate or junk entry → click Delete
7. Keep ONLY these Miniconda entries:
Entry to KEEP Why it is needed
D:\miniconda3 The base conda installation
D:\miniconda3\Scripts The conda command itself
Python Environment Cleanup Guide | Confidential | Page 3 of 14
D:\miniconda3\condabin Conda initialisation
D:\miniconda3\Library\bin DLL libraries conda needs
⚠️ Be careful — only delete obvious duplicates
If you are unsure whether to delete an entry, leave it alone.
Focus on removing entries that appear TWICE, or old Python installs like C:\Python39.
Never delete System32, Windows, or anything that looks like an operating system path.
1c — Re-initialise Conda for Anaconda Prompt
After cleaning PATH, run this command to make sure conda sets itself up correctly:
conda init [Link]
# Then CLOSE and REOPEN Anaconda Prompt
# Confirm conda is working:
conda --version
# You should see something like: conda 24.x.x
STEP
Clean the Base Environment
2 Base should contain almost nothing — it is not a working environment
🔑 The Golden Rule of Base
The base environment is like the engine room of a ship — you do not live there.
Base should only contain conda itself and nothing else.
All your actual work (research, trading, AI) happens in separate named environments.
2a — See What Is in Base
conda activate base
# List everything installed in base
conda list
Common packages you will likely see that should NOT be in base:
• spyder, jupyterlab, jupyter, notebook
• numpy, pandas, matplotlib, scipy, scikit-learn
• tensorflow, torch, keras
• requests, flask, django
Python Environment Cleanup Guide | Confidential | Page 4 of 14
2b — Remove Non-Essential Packages from Base
Remove packages one at a time. If conda says a package is not installed, that is fine — just move to
the next.
conda activate base
# Remove data science / IDE packages from base
conda remove spyder -y
conda remove jupyter jupyterlab notebook -y
conda remove numpy pandas matplotlib scipy -y
conda remove scikit-learn seaborn -y
# Clean up the download cache to free disk space
conda clean --all -y
💡 What if conda says a package is not installed?
That is perfectly fine — just move on to the next command.
The -y flag means yes to all so conda doesn't ask you to confirm each removal.
STEP
Create Three Clean Environments
3 One environment per purpose — isolated, predictable, reproducible
Why Three Environments?
Each environment is a separate, self-contained Python installation with its own packages. They cannot
interfere with each other. Think of them as three separate toolboxes.
Environment Purpose and what goes inside
research_env Data analysis, backtesting, Jupyter notebooks, Spyder IDE, charts
trading_env Live trading systems, NQ-ES pipeline, IBKR connectivity, execution code
ai_env AI tools, LLM API clients, prompt experiments, Anthropic / OpenAI SDKs
3a — Create research_env
# Create the environment with Python 3.11
conda create -n research_env python=3.11 -y
# Activate it
conda activate research_env
# Install core data science packages
conda install numpy pandas matplotlib scipy statsmodels -y
# Install Jupyter via pip (more reliable than conda for Jupyter)
pip install jupyterlab
Python Environment Cleanup Guide | Confidential | Page 5 of 14
# Verify — should show the research_env python path
python -c "import sys; print([Link])"
The output should contain research_env in the path — for example:
D:\miniconda3\envs\research_env\[Link]
3b — Create trading_env
# Create with Python 3.10 (stability for trading systems)
conda create -n trading_env python=3.10 -y
# Activate
conda activate trading_env
# Install trading essentials
conda install numpy pandas scipy -y
pip install pyarrow fastparquet python-dotenv schedule
# If you use Interactive Brokers, add this too:
# pip install ib_insync
# Verify
python -c "import sys; print([Link])"
3c — Create ai_env
# Create with Python 3.11
conda create -n ai_env python=3.11 -y
# Activate
conda activate ai_env
# Install AI / LLM packages
pip install openai anthropic
pip install transformers datasets
# Verify
python -c "import sys; print([Link])"
3d — Confirm All Three Environments Exist
# Deactivate current env and list all
conda deactivate
conda env list
# Expected output:
# base * D:\miniconda3
# ai_env D:\miniconda3\envs\ai_env
# research_env D:\miniconda3\envs\research_env
# trading_env D:\miniconda3\envs\trading_env
Python Environment Cleanup Guide | Confidential | Page 6 of 14
STEP
Set Up Spyder for research_env
4 Spyder is your IDE for research and data analysis
Option A — Install Spyder as a Standalone App (Recommended)
The cleanest way to use Spyder is to download it as a standalone application from the official website.
This avoids any conda conflicts.
8. Go to: [Link] and download the Windows installer
9. Install it — it will install its own internal Python (ignore that)
10. After install, open Spyder
11. Go to: Tools → Preferences → Python Interpreter
12. Select: Use the following Python interpreter
13. Click the folder icon and navigate to:
D:\miniconda3\envs\research_env\[Link]
14. Click Apply and OK
15. Restart Spyder
16. Verify by running this in Spyder's console:
import sys
print([Link])
You should see the research_env path in the output.
Option B — Install Spyder Inside research_env
If you prefer Spyder to be inside the conda environment:
conda activate research_env
conda install spyder -y
# Launch Spyder from this environment
spyder
Python Environment Cleanup Guide | Confidential | Page 7 of 14
Restore Your Spyder Settings Backup
After Spyder is working correctly, restore your saved preferences:
17. Close Spyder completely
18. Open File Explorer → navigate to C:\Users\YourName\
19. Show hidden folders (View → Hidden items)
20. Delete (or rename) the current .spyder-py3 folder
21. Copy your backed-up .spyder-py3 from D:\backups\ to C:\Users\YourName\
22. Reopen Spyder — your previous settings, theme, and shortcuts are restored
STEP
Bind IDEs to the Right Environment
5 Every IDE must be explicitly told which Python to use
⚠️ Never trust automatic detection
IDEs like PyCharm, Cursor, and VS Code will try to auto-detect Python.
Their auto-detection is often wrong — they may pick the base Python or a wrong version.
Always manually set the interpreter. It takes 30 seconds and saves hours of confusion.
PyCharm → trading_env
23. Open PyCharm → open your project
24. Go to: File → Settings → Project → Python Interpreter
25. Click the gear icon → Add Interpreter → Conda Environment
26. Select: Existing environment
27. Click the folder icon and navigate to:
D:\miniconda3\envs\trading_env\[Link]
28. Click OK → Apply
VS Code / Cursor / Windsurf → Choose Per Project
29. Open the project folder in VS Code
30. Press Ctrl + Shift + P → type Python: Select Interpreter → press Enter
31. A list appears — choose the one containing the environment name you want
32. If it does not appear, click Enter interpreter path and paste the full path
Project Type Path to use as interpreter
Research / notebooks D:\miniconda3\envs\research_env\[Link]
Python Environment Cleanup Guide | Confidential | Page 8 of 14
Trading systems D:\miniconda3\envs\trading_env\[Link]
AI / LLM work D:\miniconda3\envs\ai_env\[Link]
STEP
Remove Unwanted Packages Safely
6 Use this checklist to clean up each environment without breaking anything
🔑 The right way to remove packages
Always activate the specific environment before removing packages from it.
Remove packages one at a time and check that nothing breaks before removing the next.
After removal, test your main scripts to confirm they still run.
How to See What Is Installed in an Environment
# Activate the environment you want to inspect
conda activate research_env
# See all installed packages with their versions
conda list
# Or export to a file for easier reading
conda list > D:\backups\installed_research_env.txt
How to Remove a Package
# Always activate the environment first
conda activate research_env
# Try to remove with conda first
conda remove package_name -y
# If conda says it was installed with pip, use pip instead
pip uninstall package_name
Safe Packages to Remove (Common Junk)
These are typically safe to remove from environments where you do not use them:
Package Safe to remove if...
spyder You installed Spyder as a standalone app (Option A)
notebook You prefer JupyterLab over classic Jupyter Notebook
seaborn You only use matplotlib for charts
scikit-learn You do not do machine learning in that environment
Python Environment Cleanup Guide | Confidential | Page 9 of 14
pillow / PIL You do not process images
flask / django You do not build web apps
requests You are not making HTTP calls in that environment
beautifulsoup4 / bs4 You do not scrape web pages
Packages to NEVER Remove
These are core dependencies — removing them will break conda or Python itself:
• pip — the package installer
• setuptools — required by pip
• wheel — required to install packages
• conda — the environment manager
• python — obviously!
• certifi, urllib3, charset-normalizer — SSL and networking foundations
After Removing — Always Verify
After any removal, run a quick check to confirm your main packages still work:
conda activate research_env
python -c "import numpy; print('numpy OK:', numpy.__version__)"
python -c "import pandas; print('pandas OK:', pandas.__version__)"
python -c "import matplotlib; print('matplotlib OK:', matplotlib.__version__)"
# All three should print OK with a version number
# If any gives an error, reinstall that package:
conda install numpy -y
STEP
Save Environment Files Per Project
7 Reproducibility — rebuild any environment in one command
Once each environment is clean and working, save a snapshot of it. This file lets you rebuild the exact
same environment on any computer, or after a fresh Windows install.
# For research_env
conda activate research_env
conda env export --no-builds > D:\Projects\research\[Link]
# For trading_env
conda activate trading_env
conda env export --no-builds > D:\Projects\trading_systems\[Link]
# For ai_env
conda activate ai_env
conda env export --no-builds > D:\Projects\ai_experiments\[Link]
Python Environment Cleanup Guide | Confidential | Page 10 of 14
How to Restore from a .yml File
# If you ever need to rebuild an environment from scratch:
conda env create -f [Link]
# To rebuild with a new name:
conda env create -n new_name -f [Link]
Python Environment Cleanup Guide | Confidential | Page 11 of 14
📋 Quick Reference Card
Daily Commands — The Only Commands You Need Day-to-Day
Task Command to run in Anaconda Prompt
Switch to research conda activate research_env
environment
Switch to trading environment conda activate trading_env
Switch to AI environment conda activate ai_env
Go back to base conda deactivate
Check which Python is python -c "import sys; print([Link])"
running
See all environments conda env list
See what is installed in current conda list
env
Install a package conda install package_name -y OR pip install package_name
Remove a package conda remove package_name -y
Clean up download cache conda clean --all -y
The 5 Rules — Stick to These Always
📌 Rules for a Healthy Python Setup
1. Never do real work in base. Activate a named environment first.
2. Always verify the interpreter. Run python -c "import sys; print([Link])" when in
doubt.
3. One environment per purpose. Research = research_env. Trading = trading_env. AI =
ai_env.
4. Back up before big changes. Run conda env export > [Link] before installing or
removing packages.
5. Bind IDEs explicitly. Never trust auto-detection. Set the interpreter manually in every IDE.
Folder Structure to Keep
D:\
├── miniconda3\ ← Conda installation (do not touch)
Python Environment Cleanup Guide | Confidential | Page 12 of 14
│ └── envs\
│ ├── research_env\
│ ├── trading_env\
│ └── ai_env\
│
├── Projects\
│ ├── research\
│ │ └── [Link] ← Backup of research_env packages
│ ├── trading_systems\
│ │ └── [Link] ← Backup of trading_env packages
│ └── ai_experiments\
│ └── [Link] ← Backup of ai_env packages
│
└── backups\
├── backup_base.yml
├── backup_myenv.yml ← Your old environment backups
├── .spyder-py3\ ← Spyder settings backup
└── packages_*.txt ← Package lists from before cleanup
Troubleshooting — Common Problems
Problem Solution
conda: command not found Reopen Anaconda Prompt (not PowerShell). Run conda init
[Link] and reopen.
ModuleNotFoundError You are in the wrong environment. Activate the correct one and
install the package.
Wrong Python path showing In your IDE, manually set the interpreter path. Do not use auto-
detect.
conda env create fails with Try: conda create -n env_name python=3.10 --no-deps -y then
conflicts install packages one by one.
Spyder opens but imports Spyder is using a different Python. Go to Tools → Preferences →
fail Python Interpreter and set the correct path.
Package breaks after Restore it: conda install package_name -y or pip install
removal package_name
Disk space still high after Run: conda clean --all -y and also check if old PyCharm/IDE folders
clean are on C:\
✅ Final Verification Checklist — Do This After All Phases Are Done
☐ conda env list shows: base, research_env, trading_env, ai_env
☐ Activating each env and running python -c "import sys; print([Link])" shows the
correct path
☐ Spyder is bound to research_env and imports work
☐ PyCharm is bound to trading_env
☐ D:\backups\ contains .yml files for all old environments
☐ D:\backups\.spyder-py3 contains your Spyder settings
☐ Each project folder has its own [Link]
☐ Base environment has no data science packages (conda list shows only conda core)
Python Environment Cleanup Guide | Confidential | Page 13 of 14
You now have full control over your Python execution layer. Every script you run — you
know exactly which Python is running it.
Python Environment Cleanup Guide | Confidential | Page 14 of 14