Python virtual environment Venv: Your project development weapon
If you are learning Python development, you may have heard of "virtual environment". At first, it may sound a little mysterious, but believe me, this small tool will become your best friend. Let us understand its importance, how to use, and the possibility it brings.
The virtual environment is like the private work area of your Python project. It is an isolated environment, you can be in it:
Imagine, you are dealing with two Python projects:
Without a virtual environment, installing these two versions on the same machine will cause confusion.
With the virtual environment, you can switch between them seamlessly!
Source
1. Install Venv
2. Create a virtual environment
<code>sudo apt install python3-venv</code>
Here, is the name of your virtual environment. You can name it at will.
<code>python3 -m venv venv</code>
venv
4. Install dependency item
<code>source venv/bin/activate</code>
Now, you can install the package specific to your project:
<code>(venv) lovestaco@i3nux-mint:~$</code>
After the completion, the disable environment:
<code>pip install flask</code>
The possibility is infinite! Here are some ideas:
<code>deactivate</code>
: Try a new library or framework without worrying about destroying your system settings.
Easy collaboration
<code>sudo apt install python3-venv</code>
Just a few commands, you can create, activate and manage the isolation Python environment for your project.
So, next time you start a Python project, remember to start a virtual environment.
I have been developing a very convenient tool called Liveapi.
Liveapi helps you complete the documentation of all back -end API in a few minutes.
Using Liveapi, you can quickly generate a transaction interactive API document, allowing users to execute the API directly from the browser.
If you are tired of creating a document for your API, this tool may make your life easier.
The above is the detailed content of Python Virtual Environments: Why You Need Them and How to Use Them. For more information, please follow other related articles on the PHP Chinese website!