When I started learning Python and was thinking about creating an app, it seems that it is common to create a virtual environment, so I will summarize the operation method.
The reason why we need a virtual environment in the first place is to make it possible to use the appropriate version of the library and Python for each application.
It wasn't necessary while I was just starting to learn Python and learning the basics such as grammar, but it seems better to use a virtual environment when I'm about to create more and more apps.
Conda for using Anaconda for data science is famous, and there seems to be many others such as virtualenv which is the base of venv, but here I will explain the Python standard ** venv **.
Since venv is a Python standard, just execute the following command in any directory. A folder is created with the entered virtual environment name.
python -m venv [Virtual environment name]
Modules can be specified by adding the **-m ** option to the python command. When specifying a module, specify only the module name and no extension (.py) is required.
After creating the virtual environment, move to the created folder and execute the following command.
If ** PSSecurityException ** occurs on Windows, execute the following command.
set-executionpolicy remotesigned -scope process
Note that the process may remain unless the virtual environment executed by activate is terminated. When you are done, use the deactivate command to deactivate the virtual environment and exit.
If you want to return to the initial state for some reason, move to the parent directory where the virtual environment was created and execute the following command.
python -m venv --clear [Virtual environment name]
Delete the created folder after deactivating it with deactivate.
rm -rf [Virtual environment name]