An environment such that the Python interpreter, libraries and scripts installed into it are isolated from those installed in other virtual environments. Meaning each tool you have will be isolated from each other and won't conflict with each other, as part of your OS (operating system).
You really don't have to be a python expert or developper to use a virtual environment, even though all Python Devs use a VE.
Think about this for a second, you do a lot of OSINT and you love using all the best python tools, the problem is that you have accumulated 30 or 40 tools that start to conflict with each other and you find yourself writing/starting an issue on Github because your awesome OSINT python tool is no longer operational.
One OSINT python tool may require of you to install Package A version 1.0 to your python lib (Library), another OSINT tool may require you to install Package A version 2.2, you install the requirements, and now you find that your tools stop working because of conflicting packages/python libs.
How about not having these issues by isolating the tools? π§
Image Above: Piotr PΕoΕski, https://mljar.com
Requirements: First of all, you need to have Python installed: https://www.python.org/downloads/
Install Virtual Environment Command:
$ pip3 install virtualenv
Now let's create your project/tool folder: (mkdir
stands for make directory
)
$ mkdir project-Osint1
$ cd project-Osint1
cd
command = change directory
Now that the the project-osint1
folder has been created, we have the luxury of choosing what python version we want to use in our virtual environment, and the virtual environment name.
We can do this with the following command:
$ python3.9 -m venv myvenv
You can choose any python version and any name for your virtual environment,it is recommended to keep it short and simple.
Remember KISS:πKeep It Simple Stupid
Everything needed has been created, but we need to activate the virtual environment in order for it to be useable. Activation command:
$ source myvenv/bin/activate
recap: source <your virtual environment name>/bin/activate
Let's check the Python Version: Command:
$ python --version
Let's check if everything is working correctly with one commmand:
$ pip list
This is an example I am using with the OSINT python tool called Twayback, after the pip list
command, we can see all the libs and requirements that only concern Twayback, which is isolated from the rest of the libs on my system.
You may want to check the current version of virtualenv:
$ virtualenv --version
Make sure Pip is up to date:
$ python3 -m pip install --upgrade pip
$ pip3 install virtualenv
$ virtualenv venv
(or the name you choose instead of venv)
$ source venv/bin/activate
Success! β , your Virtual Environment has been created and is now activated, you can make the checks with the check commands given above, now install your python OSINT tools (git clone) , dependencies, requirements, libs etc.. You now have a much higher success rate with your OSINT Python tools and less chance of having to open an issue on Github , most of the issues that OSINT Analysts have is due to a lack of knowledge with Python, they keep adding dozens and dozens of tools on top of each other without isolating them, so the tools all conflict with each other, thus, creating a big messy salad of packages/libs all conflicting with one another.
To Deactivate and return to the default sys environment, the command is KISS, I bet you can guess what the command is right? π€
$ deactivate
cd {directory}
source {name of virtual environment}/bin/activate
Simple as that !
Enjoy using your Python π Virtual Environment !