惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
博客园 - 司徒正美
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
D
Docker
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
腾讯CDC
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
I
InfoQ
雷峰网
雷峰网
The Cloudflare Blog
美团技术团队
Engineering at Meta
Engineering at Meta

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Stop Breaking Your System Python: A Practical Guide to Ma...
Iman · 2026-05-15 · via DEV Community

Iman

Every Python developer eventually hits the same wall: one project needs Python 3.9, another requires 3.11, and the new one won't run on anything below 3.12. The instinct is to upgrade globally — which promptly breaks something else.
There's a better way. Two tools worth knowing: pyenv and conda. They solve the same problem differently, and knowing which to reach for matters.

pyenv — Lightweight, Automatic Version Switching
pyenv lets you install and switch between Python versions at the system, user, or project level. Critically, it never touches your system Python.
Installing pyenv
Linux / Mac:
bashcurl https://pyenv.run | bash
Add this to your ~/.bashrc or ~/.zshrc:
bashexport PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
Windows — use pyenv-win:
powershellInvoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"
Basic Usage
bash# See available versions
pyenv install --list

Install a specific version

pyenv install 3.11.9

Set global default

pyenv global 3.11.9

Set version for current project only

pyenv local 3.10.14
pyenv local creates a .python-version file in your project directory. Every time you cd into that folder, pyenv switches automatically — no manual toggling.
Per-Project Workflow
bashcd my-project
pyenv local 3.10.14
python --version # Python 3.10.14

cd ../other-project
pyenv local 3.12.0
python --version # Python 3.12.0
Clean and automatic.

conda — Full Environment Management
conda handles Python versions and packages together. It's heavier than pyenv but earns its weight when dependencies get complex — particularly in data science and ML.
Installing conda
Download Miniconda — the minimal install — for Windows, Linux, or Mac.
Basic Usage
bash# Create an environment with a specific Python version
conda create -n myenv python=3.10

Activate it

conda activate myenv

Install packages

conda install numpy pandas

Deactivate

conda deactivate
Per-Project Workflow
bashcd my-project
conda activate project-39 # Python 3.9 environment

cd ../other-project
conda activate project-312 # Python 3.12 environment
Unlike pyenv, switching isn't automatic — you activate manually. Small trade-off for what you get in return.

pyenv vs conda — Which One?
pyenvcondaPython version switchingAutomatic (per directory)Manual activationPackage managementNo — use pip + venvYes, built-inBest forGeneral / backend / web devData science / MLWindows supportVia pyenv-win (limited)ExcellentOverheadLightweightHeavier
Use pyenv if you want lightweight, automatic version switching per project.
Use conda if you're in data science, need environment and package management together, or are primarily on Windows.

The Ideal Setup: pyenv + venv Together
For most developers, this combination covers everything:
bash# Set Python version with pyenv
pyenv local 3.11.9

Create a virtual environment

python -m venv .venv

Activate it

source .venv/bin/activate # Linux/Mac
.venv\Scripts\activate # Windows

Install dependencies

pip install -r requirements.txt
pyenv handles the version. venv handles dependency isolation. Best of both.

Common Issues Worth Knowing
pyenv: command not found after install
Your shell config wasn't reloaded. Run source ~/.bashrc (or ~/.zshrc) after editing it, or close and reopen your terminal.
conda: environment not activating in scripts
Run conda init once after installing, then restart your terminal. This adds the necessary hooks to your shell profile.
python --version still shows system Python after pyenv local
Make sure the pyenv init lines are actually in your shell config and that you've reloaded it. Running pyenv versions should list your installed versions.

Quick Reference
bash# pyenv
pyenv install 3.11.9
pyenv local 3.11.9 # project-level
pyenv global 3.11.9 # system-level
pyenv versions # list installed versions

conda

conda create -n myenv python=3.11
conda activate myenv
conda deactivate
conda env list # list all environments

Managing Python versions correctly is one of those things that saves you hours of debugging later. Set it up once, stop thinking about it.
If you're running into an issue not covered here, drop it in the comments.