Building a Python virtual environment

Introduction

When developing an application, there is also work in a virtual environment, so I will summarize the procedure.

Creating a virtual environment

In the terminal, go to the project for which you want to build a virtual environment. Go to it and run the following command:

$ python -m venv myenv(The name of the virtual environment)
$ ls
myenv

This time I created a virtual environment named myenv. When you display the contents of the target project with ls, a virtual environment with the specified name is created.

Enter the virtual environment

Now that we have built the virtual environment, we need to "enter" the virtual environment. To enter the virtual environment, type the following command.

$source myenv (name of virtual environment)/bin/activate
(myenv)$

There is a (myenv) in front of the $. With this, it will be displayed that you are in a virtual environment.

Exit from the virtual environment

You may want to finish your work in a virtual environment after the work has settled down. In such a case, type the following command to "exit" from the virtual environment.

(myenv)$ deactivate
$

There is no (myenv) before the $. You are now out of the virtual environment.

in conclusion

Basically, there is no problem if you remember `source virtual environment name / bin / activate``` when entering and `deactivate``` when exiting.

Recommended Posts

Building a Python virtual environment
Building a Python virtual environment
[Mac] Building a virtual environment for Python
[Python] Web development preparation (building a virtual environment)
Building a Python environment on Mac
Building a Python environment on Ubuntu
Create a virtual environment with Python!
Building and enabling a python virtual environment, etc. (venv)
Building a Python3 environment with Amazon Linux2
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
Building a Python 3.6 environment with Windows + PowerShell
python virtual environment Pipenv
Creating a python virtual environment on Windows
[Python] Building a virtual python environment for the pyramid tutorial (summary)
virtual environment in python
Create a Python environment
Build a python virtual environment with pyenv
Building a Python development environment for AI development
Add a Python virtual environment to VSCode
Virtual environment with Python 3.6
From installing Ansible to building a Python environment in Vagrant's virtual environment
How to create a Python virtual environment (venv)
Ubuntu18.04.05 Creating a python virtual environment in LTS
Building a python environment with virtualenv and direnv
Building a Python environment with WLS2 + Anaconda + PyCharm
Create a virtual environment with conda in Python
Build a simple Python virtual environment without pyenv
Think about building a Python 3 environment in a Mac environment
Work in a virtual environment with Python virtualenv.
Building a Python environment on a Sakura VPS server
Create a Python virtual development environment on Windows
venv: Python virtual environment management
Build a Python environment offline
Building a virtual environment for Mayavi dedicated to Python 3.6, Anaconda, Spyder users
Building a Python environment for pyenv, pyenv-virtualenv, Anaconda (Miniconda)
Write about building a Python environment for writing Qiita Qiita
Python: Creating a virtual environment (venv), starting and stopping
Recommendation of building a portable Python environment with conda
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a Python virtual environment using venv (Django + MySQL ①)
Procedure for building a CDK environment on Windows (Python)
Build a python virtual environment with virtualenv and virtualenvwrapper
conda memorandum: Building a Python environment with supercomputer ITO
Building a Python environment for programming beginners (Mac OS)
Memo for building a machine learning environment using Python
Building a kubernetes environment with ansible 2
Virtual Environment Version Control Summary Python
[Personal memo] Python virtual environment command memo
Create a python environment on centos
Build a python3 environment on CentOS7
How to build a new python virtual environment on Ubuntu
Building a python environment for artificial intelligence (Chainer / TensorFlow / CSLAIER)
Building a Python environment on a Mac and using Jupyter lab
[Django3] Display a web page in Django3 + WSL + Python virtual environment
Summary from building Python 3.4. * From source to building a scientific computing environment
Building a development environment for Android apps-creating Android apps in Python
Building a Hy environment for Lisper who hasn't touched Python
How to develop in a virtual environment of Python [Memo]
Precautions that must be understood when building a PYTHON environment
Create a virtual environment for python on mac [Very easy]