How to run python in virtual space (for MacOS)

This article describes how to do python on virtual space on macOS.

Preparation: Install Homebrew

First, use Homebrew to install pyenv and pyenv-virtualenv. Enter the following command in the terminal.

$brew install pyenv
$brew install pyenv-virtualenv

We were able to introduce a tool for handling virtual environments.

Then add the following code to your .bash_profile.

python


export PYENV_ROOT=${HOME}/.pyenv
if [ -d "${PYENV_ROOT}" ]; then
    export PATH=${PYENV_ROOT}/bin:$PATH
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
fi

Read this.

$ source ~/.bash_profile

Install your favorite Python version in pyenv.

$ pyenv install 3.x.y

Next, specify the Python version that exists in pyenv and build a virtual environment.

$ pyenv virtualenv 3.x.y test

Specify the test environment on your favorite directory.

$ pyenv local test

Now you can run the Python specified in the test environment automatically to that directory.

Recommended Posts

How to run python in virtual space (for MacOS)
How to run Leap Motion in non-Apple Python
How to run Notepad ++ Python
How to develop in Python
[For beginners] How to use say command in python!
How to run tests in bulk with Python unittest
How to run setUp only once in python unittest
[Python] How to do PCA in Python
How to collect images in Python
How to use SQLite in Python
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
Run unittests in Python (for beginners)
How to run TensorFlow 1.0 code in 2.0
How to handle Japanese in Python
How to define multiple variables in a python for statement
How to develop in a virtual environment of Python [Memo]
How to specify Cache-Control for blob storage in Azure Storage in Python
How to implement Python EXE for Windows in Docker container
[Introduction to Python] How to use class in Python?
How to access environment variables in Python
How to dynamically define variables in Python
[Itertools.permutations] How to put permutations in Python
How to configure CORS settings for Azure storage service in Python
How to work with BigQuery in Python
How to use python put in pyenv on macOS with PyCall
[Introduction to Python] How to use the in operator in a for statement?
How to get a stacktrace in python
How to display multiplication table in python
How to extract polygon area in Python
[Python] Organizing how to use for statements
How to check opencv version in python
[For beginners] How to register a library created in Python in PyPI
How to switch python versions in cloud9
How to adjust image contrast in Python
How to use __slots__ in Python class
How to dynamically zero pad in Python
How to use "deque" for Python data
How to use regular expressions in Python
How to display Hello world in python
How to use is and == in Python
How to write Ruby to_s in Python
How to run a Maya Python script
How to put a half-width space before letters and numbers in Python.
How to run a quickstart for Google Cloud Text-to-Speech .NET in Unity
CERTIFICATE_VERIFY_FAILED in Python 3.6, the official installer for macOS
How to receive command line arguments in Python
How to create a Python virtual environment (venv)
[REAPER] How to play with Reascript in Python
How to generate permutations in Python and C ++
How to embed a variable in a python string
How to implement Discord Slash Command in Python
Summary of how to import files in Python 3
Type Python scripts to run in QGIS Processing
How to simplify restricted polynomial fit in python
How to use Python Image Library in python3 series
How to implement shared memory in Python (mmap.mmap)
How to create a JSON file in Python
How to run some script regularly in Django