Overview of Python virtual environment and how to create it

Python virtual environment

I investigated the virtual environment because I was using it without knowing it well. In this article, I will briefly explain what a virtual environment is and how to create it.

What is a virtual environment?

Simply put, it's a ** space for running programs **. Install and use various libraries in this space.

Why create a virtual environment?

To solve problems such as "interference between libraries" and "incompatibility between libraries and frameworks".

Without a virtual environment ...

--If you use frameworks and libraries without a virtual environment, libraries will be added to one place more and more. --As a result, complex libraries may interfere with each other and not work well.

When using a virtual environment ...

――It is possible to select the version of python as you like and the framework library to use, such as "Virtual environment for machine learning of python3.x series" and "Virtual environment for analysis of python2.x series". Become. --As a result, problems such as interference between libraries can be avoided.

What kind of virtual environment is python?

Such. This time, I will explain how to create a virtual environment using ** venv ** below.

How to use Python virtual environment / venv

venv is ready to use with Python 3.4 and above. The command to check the python version is as follows.

$ python -V

Create a virtual environment with venv

It can be created with the following command.

$ python -m venv ****

When you create a virtual environment, the files in the virtual environment are set in the working directory. You can check it with the following command.

$ ls -la

Next, enable the created virtual environment with the following command.

$ source ****/bin/activate

Recommended Posts

Overview of Python virtual environment and how to create it
How to create a Python virtual environment (venv)
How to develop in a virtual environment of Python [Memo]
Overview of how to create a server socket and how to establish a client socket
When I tried to create a virtual environment with Python, it didn't work
[Python] How to create a local web server environment with SimpleHTTPServer and CGIHTTPServer
Environment construction of python and opencv
How to build a new python virtual environment on Ubuntu
[python] Summary of how to retrieve lists and dictionary elements
Create a virtual environment with Python!
How to create a virtual bridge
[Python] Summary of how to use split and join functions
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
Comparison of how to use higher-order functions in Python 2 and 3
How to convert Youtube to mp3 and download it super-safely [Python]
[Django] Memo to create an environment of Django + MySQL + Vue.js [Python]
[Python] How to get the first and last days of the month
How to use Serverless Framework & Python environment variables and manage stages
Convert the result of python optparse to dict and utilize it
How to build Python and Jupyter execution environment with VS Code
[Python] Summary of how to use pandas
How to package and distribute Python scripts
How to access environment variables in Python
How to install and use pandas_datareader [Python]
Python virtual environment and packages on Ubuntu
How to create an NVIDIA Docker environment
About the virtual environment of python version 3.7
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
python: How to use locals () and globals ()
[Python] How to calculate MAE and RMSE
How to use Python zip and enumerate
How to add python module to anaconda environment
Summary of how to use Python list
[Python2.7] Summary of how to use subprocess
[Question] How to use plot_surface of python
[Python] How to specify the window display position and size of matplotlib
Steps to create a Python virtual environment with VS Code on Windows
Migration from Python2 to Python3 (Python2 is rebuilt as a virtual environment and coexists)
How to share a virtual environment [About requirements.txt]
[Python] How to use two types of type ()
How to generate permutations in Python and C ++
Summary of how to import files in Python 3
How to create explanatory variables and objective functions
How to create a JSON file in Python
Create an environment of 64bit Windows + python 2.7 + MeCab 0.996
[Python] How to read data from CIFAR-10 and CIFAR-100
Summary of how to use MNIST in Python
How to convert SVG to PDF and PNG [Python]
How to specify attributes with Mock of python
python development environment -use of pyenv and virtualenv-
[Venv] Create a python virtual environment on Ubuntu
How to get dictionary type elements of Python 2.7
[Note] How to create a Ruby development environment
[Python] How to use hash function and tuple.
List of Python code to move and remember
From Python environment construction to virtual environment construction with anaconda
How to install Cascade detector and how to use it
Procedure to set hydrogen of atom (virtual environment)
[Python] How to save the installed package and install it in a new environment at once Mac environment
Create a Python virtual development environment on Windows