Make a note of how to create a virtual environment with python, how to enter (activate) the virtual environment, how to exit, etc. When I create a web application with python and deploy it, I write a library with reqirements.txt, but it is one of the causes that it becomes heavy if there is a library that is not used in the application. In such a case, use a virtual environment.
The activation method is slightly different for Windows and Mac.
Prepare a folder to create a virtual environment. This time, assuming that Desktop has a folder called test, create a virtual environment here.
Open Anaconda Prompt for Windows or Terminal for Mac and set the test folder to the current directory. In this state
python -m venv venv
And press Enter. This will create a folder named venv. This folder is the virtual environment. Virtual environments that are no longer needed can be destroyed by deleting this folder.
On windows
venv¥Scripts¥activate.bat
On Mac
source venv/bin/activate
You can enable it with. When you run this command, (base) becomes (venv). If this happens, you are in a virtual environment.
Install the required libraries in (venv) state (pip, conda, etc.)
deactive
Just hit.
that's all.
Recommended Posts