Build a python virtual environment with virtualenv and virtualenvwrapper

Overview

I often use python2.7! But suddenly I have to use python3 series! Isn't it possible to use python3 system without breaking the environment of python2.7? A note of virtualenv that is convenient at that time.

virtualenv insco

brew install pyenv-virtualenv

virtualenvwrapper Insco

pip install virtualenvwrapper

Add the following to bash_profile etc. and execute with source command.

if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
    export WORKON_HOME=$HOME/.virtualenvs
    source /usr/local/bin/virtualenvwrapper.sh
fi

Download and check python3 series

pyenv install 3.3.6
pyenv versions

Now it looks like this:

MacBook-Pro:~ hoge$ pyenv versions
* system
  3.3.6 (set by /Users/hoge/.pyenv/version)

python3.3.6 is stored in /Users/hoge/.pyenv/shims/python3.3.

Create a python3.3 environment

mkvirtualenv --python=/Users/hoge/.pyenv/shims/python3.3 python3.3[Any name]

(python3.3)MacBook-Pro:~ hoge$ python -V
Python 3.3.6  # python3.3.6 available.
(python3.3)MacBook-Pro:~ hoge$  #previous()Indicates that is using the environment created by the above command.
(python3.3)MacBook-Pro:~ hoge$ which python
/Users/hoge/.virtualenvs/python3.3/bin/python #It is the path specified by mkvirtualenv.
(python3.3)yusuke-no-MacBook-Pro:~ hoge$ which pip
/Users/hoge/.virtualenvs/python3.3/bin/pip #The path of pip also changes.

Deactivate (exit from the environment you are using) and activate (change the environment)

deactivate       #Deactivate
workon python3.3 #Activate

With this, for example, if you install PILLOW with pip in the python3.3 environment, you can use it in the 3.3 environment, but if you deactivate it, you can not use PILLOW.

Recommended Posts

Build a python virtual environment with virtualenv and virtualenvwrapper
Build a python virtual environment with virtualenv and virtualenvwrapper
Build python virtual environment with virtualenv
Build a python virtual environment with pyenv
Building a python environment with virtualenv and direnv
Work in a virtual environment with Python virtualenv.
Create a virtual environment with Python!
Building a virtual environment with Python 3
Clean python environment with pythonz and virtualenv
Build a modern Python environment with Neovim
Virtual environment with Python 3.6
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Build a Python environment on your Mac with Anaconda and PyCharm
Try using virtualenv, which can build a virtual environment for Python
Build a python environment with ansible on centos6
Create a virtual environment with conda in Python
[Python] Build a Django development environment with Docker
[Memo] Build a virtual environment with Pyenv + anaconda
Commands for creating a python3 environment with virtualenv
Build a Python environment with OSX El capitan
Quickly build a Python Django environment with IntelliJ
Build PyPy and Python execution environment with Docker
Build a Python machine learning environment with a container
Build a python execution environment with VS Code
Manage python environment with virtualenv
Build python3 environment with ubuntu 16.04
Build python environment with direnv
Building a Python virtual environment
Build a Python environment offline
Building a Python virtual environment
Build a Python virtual environment using venv (Django + MySQL ①)
Build a machine learning application development environment with Python
Building and enabling a python virtual environment, etc. (venv)
Build a Django environment for Win10 (with virtual space)
Build a numerical calculation environment with pyenv and miniconda3
Build a Python + bottle + MySQL environment with Docker on RaspberryPi3! [Trial and error]
Build Mysql + Python environment with docker
Build a python3 environment on CentOS7
Build a machine learning scikit-learn environment with VirtualBox and Ubuntu
Build a Python environment and transfer data to the server
How to build a python2.7 series development environment with Vagrant
Build a python environment with pyenv (OS X El Capitan 10.11.3)
Build a Python environment with WSL + Pyenv + Jupyter + VS Code
[Pyenv] Building a python environment with ubuntu 16.04
Building a Python3 environment with Amazon Linux2
Easily build a development environment with Laragon
Build Jupyter Lab (Python) environment with Docker
Build and test a CI environment for multiple versions of Python
Build Python3 and OpenCV environment on Ubuntu 18.04
Build a python environment on MacOS (Catallina)
Python virtual environment and packages on Ubuntu
Build a Tensorflow environment with Raspberry Pi [2020]
Let's create a virtual environment for Python
A memo with Python2.7 and Python3 on CentOS
Building a Python 3.6 environment with Windows + PowerShell
I want to build a Python environment
Build a Fast API environment with docker-compose
[Mac] Building a virtual environment for Python
Creating a python virtual environment on Windows
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
Create a virtual environment with Python_Mac version