[Personal memo] Python virtual environment command memo

What A note about Python virtual environments and commands. There are many good articles that can be used as a reference, so make a note of the contents in your own environment. I hope it will be helpful to other people.

environment

Virtual environment this and that

pyenv Multiple versions of Python can coexist. For example, install Python 3.8.3 and Python 3.7.2 on your PC and The default (global) is Python 3.7.2, but only certain directories should be Python 3.8.3. You can also say.

virtualenv You can build multiple environments with the same version of Python. For example Environment A has Python 3.7.2 + TensorFlow Environment B is Python 3.7.2 + Keras You can create such an environment individually.

venv A virtual environment program that comes standard with Python. I feel that virtualenv is easier to understand, such as command operations. (I personally use virtualenv instead of venv.)

conda Virtual environment program included in Anaconda (I can't talk much because of lack of learning. I will take another opportunity ...)

Environment construction memo

How to install pyenv

--There is a way to install pyenv after installing Homebrew --The following Progate tutorial site is useful -Prepare a Python development environment! (Mac) | Learn from the basics if you're an introduction to programming Progate --There is also a way to install by git clone -Python virtual environment | Building a Python development environment with pyenv and vertualenv

pyenv command list

##Check the Python version that can be installed
pyenv install --list

##Installing a specific version of Python
pyenv install 3.7.2

##Checking the installed Python version
pyenv versions
# * system (set by /Users/username/.pyenv/version)
#   3.7.2
#   3.8.3

##The substance of the installed Python is~/.pyenv/versions/Saved under the directory
cd ~/.pyenv/versions
ls
# 3.7.2    3.8.3

##Specify the default Python version for PC-wide use
pyenv global 3.7.2

##pyenv versions command or python-You can check the version with the V command
pyenv versions
#   system
# * 3.7.2 (set by /Users/username/.pyenv/version)
#   3.8.3

##How to change the Python version only for a specific directory (make it local)
cd ./sample
pyenv local 3.8.3

##pyenv verions command or python-You can check the version with the V command
python -V
# Python 3.8.3

##Delete virtual environment
pyenv uninstall 3.7.2

How to install virtualenv

--Pip install is common Note: You can also install from pyenv (see below)

##How to install virtualenv
pip install virtualenv

##Creating and using a virtual environment (wherever you create it)
virtualenv ~/.virtualenvs/first-env
source ~/.virtualenvs/first-env/bin/activate

##Disable virtual environment
deactivate

##Delete virtual environment
rm -rf ~/.virtualenvs/first-env

virtualenv supplement

--At the following site, virtualenv is installed from pyenv. It looks convenient. -Python virtual environment | Building a Python development environment with pyenv and vertualenv --However, in my environment where pyenv was installed using Homebrew, the command pyenv virtualenv 3.7.2 project_x could not be executed. (pyenv: no such command `virtualenv') --I will add it when the cause etc. are known.

Recommended Posts

[Personal memo] Python virtual environment command memo
My python environment memo
python virtual environment Pipenv
virtual environment in python
Basic Python command memo
Virtual environment with Python 3.6
Building a Python virtual environment
venv: Python virtual environment management
[MEMO] [Development environment construction] Python
python standard virtual environment venv
Building a Python virtual environment
Virtual Environment Version Control Summary Python
Python environment construction memo on Windows 10
Python memo
Build python virtual environment with virtualenv
Python memo
Create a virtual environment with Python!
Python environment construction memo on Mac
Building a virtual environment with Python 3
Python colorama Color memo (Cmder environment)
How to develop in a virtual environment of Python [Memo]
python memo
Vim + Python development environment setting memo
command memo
Python memo
[Personal memo] Python sequence type / mapping type
find / grep command (beginner's personal memo)
Command memo
Emacs Python development environment construction memo
Operation memo of Conda virtual environment
Linux command (basic in basic) personal memo
Python memo
Python memo
Python & Machine Learning Study Memo: Environment Preparation
Python virtual environment and packages on Ubuntu
About the virtual environment of python version 3.7
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
Effortlessly vscode + venv virtual environment (Windows) memo
[Mac] Building a virtual environment for Python
Creating a python virtual environment on Windows
Build a python virtual environment with pyenv
Add a Python virtual environment to VSCode
Free Python runtime environment Google Colaboratory memo
[OpenCV] Personal memo
[Python] Memo dictionary
python beginner memo (9.2-10)
Python environment construction
python environment settings
python beginner memo (9.1)
python windows environment
scp command memo
Environment construction (python)
Beginner virtual environment
who command memo
Linux # Command Memo 1
★ Memo ★ Python Iroha
python environment construction
[Python] EDA memo
Python 3 operator memo
Python --Environment construction