In: Computer Science
what does activate.bat mean when working with python in the command prompt or the anaconda prompt (please be detailed)
Before we go into what activate.bat is , let's understand what Virtual Environments are.
Virtual Environments :-
Virtualenv is a tool that is used to create isolated Python environments. Virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need.
--------------------------------------
In simpler words let's understand what an evironment is with an example.
Let's suppose you have Python 3.0 installed on your machine. And you are an awesome computer hacker who builds various applications in Python. You have been working on a project for months which uses all the new packages of Python 3.0 to help you to change your exam grades by hacking into your school system.
But suddenly, Your friend has ran into some problem with his project. You being the infamous hacker, he turned to you for help. You take pity on his condition and agree to help him. You send him back home and sit down to fix his application
This is where things get interesting. You run his application, but your command prompt gets bombarded with lot's of errors. You dig deeper into the issue to find the root cause. And LO! You find the problem was that his application was entirely depended on Python 2.6 packages. And you have Python 3.0 installed.
Now what to do! Yes, You sure can roll back your python version to 2.6 but then your application will stop working. All your work will go into the drain.
This is where the idea of creating an environment hit's you.
What if you can create an another python environment, something like a standalone python with all its python packages. The changes made in this environment should not affect your actual python environement.
Guess What! After a brief search on the internet you find out that it's entirely possible.
An Python Environment / Virtual enviroment help you to create a seperate python environement where you can install any version of python and can install any packages and this will never affect your actual version of the python. It's like a mini operating system inside an operating system.
Your main environment and the created virtual environment are completely independent of each other. Any changes made in one will never affect the other environement,
And hence, You create a new environment and install Python 2.6 in the new environment and fix your friends application without hurting your application.
activate - This command is used to activate the new environment
deactivate - This command is used to deactivate the new environment and go to the normal environment.
---------------------------------------
Anaconda does the same thing. When you install Anaconda you actually create a new python environment where you write your application.
And in order to activate the Anaconda environment you use the activate.bat command.
In short this command is used to open the door to the room where you can create and execute any python application whithout harming the people outside of the room.
This activates the environment and ensures that what ever you do will not harm your actual installation of your computers python.