English translation
7. Managing Conda Environments: Activating and Deactivating
AI Article Decision Snapshot
Turn the lesson into workflow, model, budget, and security checks before choosing tools.
Use this quick snapshot before leaving the article. It keeps the next search tied to practical AI software, model/API, cost, privacy, and implementation questions.
Workflow fit
Identify the real job behind the article: coding, research, document review, support, analytics, content, or internal automation.
Model or tool decision
Decide whether the next step is a software shortlist, an AI tool comparison, an API platform choice, or a model benchmark.
Budget and usage signal
Estimate seats, API calls, prompt volume, retries, review time, and fallback work before assuming the workflow is cheap.
Security and privacy review
Check whether source code, customer data, private documents, prompts, logs, or embeddings will enter the AI workflow.
In the previous tutorial, we learned how to create new environments using conda. This step is crucial because different projects often require different packages—or different versions of Python. After creating an environment, the next essential skill is learning how to activate and deactivate it.
Activating an Environment
Activating an environment means switching your current command-line session into a specified conda environment. Once activated, all Python programs run in that terminal will use the dependencies installed in that environment.
Command to Activate an Environment
To activate a conda environment, use the following command:
conda activate environment_name
Example
Suppose we created an environment named data_analysis in the previous tutorial. We can activate it with:
conda activate data_analysis
After activation, your command-line prompt will change to display (data_analysis), indicating that you are now operating within the data_analysis environment:
(data_analysis) user@machine:~$
Now, running python in this terminal will invoke the Python interpreter and packages installed specifically in the data_analysis environment.
Installing Packages Within an Environment
Once an environment is activated, you can install packages directly into it. For example, to install numpy, run:
conda install numpy
This installs numpy exclusively into the data_analysis environment.
Deactivating an Environment
After finishing your work, you may wish to deactivate the current conda environment to return to the base environment—or switch to another one. To do so, use:
conda deactivate
Example
Continuing the earlier example, after completing work in the data_analysis environment, you can deactivate it with:
conda deactivate
After executing this command, the environment prefix disappears from your prompt:
user@machine:~$
Switching Between Multiple Environments
By repeatedly using conda activate and conda deactivate, you can easily switch among multiple environments. For instance, if you’ve also created an environment named web_dev, you can switch to it like this:
conda deactivate # First deactivate the current environment
conda activate web_dev # Then activate the new one
Summary
Activating and deactivating environments are fundamental daily tasks when managing Python environments with conda. The commands conda activate and conda deactivate allow you to flexibly switch between project-specific environments—avoiding dependency version conflicts altogether. Mastering these basic operations lays a solid foundation for the next topic: listing all existing conda environments.
In the next tutorial, we’ll cover how to list all your created conda environments—helping you manage your development setup more effectively.
Apply This Lesson
Turn this article into AI software, model, API, and security decisions.
English Article FAQ
Use this article as evidence before choosing AI tools
How should I use this AI Tutorials article?
Use it as the implementation or learning layer, then connect the idea to AI software buyer guides, tool comparisons, benchmarks, API choices, and security checks before making a production decision.
Is this English article different from the Chinese original?
The English edition is localized for global AI readers while preserving the original diagrams, screenshots, prompts, code examples, and source context from the Chinese article.
What should I read after 7. Managing Conda Environments: Activating and Deactivating?
Continue with AI Software Buyer Guides, AI Tools Workbench, Best AI Coding Agents, AI Model Benchmarks, OpenAI vs Anthropic API, or LLM Security Tools depending on the decision you need to make.
Can this article alone choose an AI product or model?
No. Treat the article as evidence and context, then validate fit with pricing, privacy requirements, integration effort, benchmark results, workflow tests, and fallback planning.
Continue