I want to create a nice Python development environment for my new Mac

Reference article (I use it almost as it is)

http://qiita.com/shizuma/items/027167c6257f1c9d2a6f

1. Add Homebrew

One command.

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2. Insert pyenv and virtualenv

$ brew install pyenv
$ brew install pyenv-virtualenv

3. Add the following to .bash_profile

PYENV_ROOT=~/.pyenv
export PATH=$PATH:$PYENV_ROOT/bin
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

Reflected.

source ~/.bash_profile

4. Add anaconda

There are various pythons that can be installed with this command

$ pyenv install --list

From this, I want to use Python2 system, so I will put the latest of anaconda2

$ pyenv install anaconda2-4.2.0

Check the python currently specified by pyenv

$ pyenv versions

* system (set by /Users/nakazonor/.pyenv/version)
  anaconda2-4.2.0

Python with the master now specified system is probably Python that comes in from the beginning

Then, specify the installed anaconda with the following command

$ pyenv global anaconda2-4.2.0

With this, Anaconda of Python2 series is specified. Since it's a big deal, let's add Python 3 system

$ pyenv install anaconda3-4.2.0

Also, if you specify anaconda3 in pyenv global, it becomes Python3.

$ pyenv global anaconda3-4.2.0

5. Create a project with virtualenv

Make a directory

$ mkdir study-conda

It seems that you should specify the installed Python version and project name like this

$ pyenv virtualenv anaconda2-4.2.0 study-conda

In the directory you just created

$ pyenv local study-conda

Then, when you enter the study-conda directory after that, the study-conda environment specified in virturalenv will be automatically set. (In short, if you put the package with pip or conda in this, it will not pollute other environments)

By the way

$ pyenv local --unset

You can cancel the local setting with.

↓ If you want to delete virtualenv, this is OK

$ pyenv uninstall study-conda

6. Try pip install

$ pip install numpy
$ pip list
numpy (1.11.3)
pip (9.0.1)
setuptools (27.2.0)
wheel (0.29.0)

You got numpy.

This time, when I go through the study-conda directory and pip list ... It's full of things, but I think it's probably because I put it in anaconda.

$ cd ..
$ pip list
alabaster (0.7.9)
anaconda-clean (1.0)
anaconda-client (1.5.1)
anaconda-navigator (1.3.1)
appnope (0.1.0)
appscript (1.0.1)
argcomplete (1.0.0)
astroid (1.4.7)
astropy (1.2.1)
Babel (2.3.4)
・
・
・

Well, anyway, I succeeded in separating the environment for each directory.

Next, I would like to be able to debug using VSCODE.

Recommended Posts

I want to create a nice Python development environment for my new Mac
I want to build a Python environment
I want to create a window in Python
I want to set up a GUI development environment with Python or Golang on Mac
[Note] How to create a Mac development environment
I tried to build a Mac Python development environment with pythonz + direnv
I want to easily build a model-based development environment
How to build a development environment for TensorFlow (1.0.0) (Mac)
Create a Python environment on Mac (2017/4)
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
I want to make input () a nice complement in python
Create a virtual environment for python on mac [Very easy]
I want to create a Dockerfile for the time being.
Create a python environment on your Mac
Let's create a virtual environment for Python
How to prepare Python development environment [Mac]
[Mac] Building a virtual environment for Python
Building a Python development environment for AI development
I wrote a script to create a Twitter Bot development environment quickly with AWS Lambda + Python 2.7
Things to watch out for when creating a Python environment on a Mac
After buying a new Mac, use pyenv + poetry to build a Python environment.
Create a Python development environment locally at the fastest speed (for beginners)
I want to easily create a Noise Model
How to create a Python virtual environment (venv)
I want to make a game with Python
I created a Dockerfile for Django's development environment
Build a Python development environment on your Mac
I want to create a plug-in type implementation
[Note] How to create a Ruby development environment
I want to write to a file with Python
Create a Python execution environment on IBM i
Create a Python virtual development environment on Windows
Create a Python environment
Create a Python development environment in 10 minutes (Mac OS X + Visual Studio Code)
I want to create a priority queue that can be updated in Python (2.7)
When I tried to create a virtual environment with Python, it didn't work
I want to embed a variable in a Python string
I want to easily implement a timeout in python
I want to generate a UUID quickly (memorandum) ~ Python ~
Build a local development environment for Laravel6.X on Mac
I want to write in Python! (2) Let's write a test
Create a comfortable Python 3 (Anaconda) development environment on windows
Create a python development environment with vagrant + ansible + fabric
I want to randomly sample a file in Python
Build a Python development environment on Mac OS X
I want to work with a robot in python.
[Python] I want to make a nested list a tuple
I want to AWS Lambda with Python on Mac!
I want to manually create a legend with matplotlib
Building a Python environment for programming beginners (Mac OS)
Create a Python development environment on OS X Lion
I want to run a quantum computer with Python
[Python] I want to use only index when looping a list with a for statement
How to build a beautiful Python environment on a new Mac and install Jupter Notebook
[Mac] I want to make a simple HTTP server that runs CGI with Python
Python environment construction For Mac
I tried to create a reinforcement learning environment for Othello with Open AI gym
I want to create a lunch database [EP1] Django study for the first time
I want to create a lunch database [EP1-4] Django study for the first time
Script to easily create a client device environment for AWS IoT (Python v2 version)
[For organizing] Python development environment