[PYTHON] Prepare the development environment with anyenv

87063.png

In my case, I write and execute code in multiple languages in my development environment. For example, perl, ruby, nodejs, python. To use these, I used plenv, rbenv, nodebrew, pyenv, etc.

However, I heard that there is something called anyenv, so I switched to this one.

** People who use more than one env should use this. Recommended.

Easy to install

If you follow README.md, it's OK.

$ git clone https://github.com/riywo/anyenv ~/.anyenv

PATH setting

zshrc has become simpler!

 # ------------------------------------------------------------------------
-# plenv
+# anyenv
 # ------------------------------------------------------------------------
-if [ -d ${HOME}/.plenv  ] ; then
-    export PATH=${HOME}/.plenv/bin:${HOME}/.plenv/shims:${PATH}
-    eval "$(plenv init -)"
-fi
-
-# ------------------------------------------------------------------------
-# rbenv
-# ------------------------------------------------------------------------
-if [ -d ${HOME}/.rbenv  ] ; then
-    export PATH=$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH
-    #export PATH="$HOME/.rbenv/bin:$PATH"
-    eval "$(rbenv init -)"
-fi
-
-# ------------------------------------------------------------------------
-# nodebrew
-# ------------------------------------------------------------------------
-if [ -d ${HOME}/.nodebrew  ] ; then
-    export PATH=${HOME}/.nodebrew/current/bin:${PATH}
-fi
-
-# ------------------------------------------------------------------------
-# pyenv
-# ------------------------------------------------------------------------
-# git://github.com/yyuu/pyenv.git
-if [ -d ${HOME}/.pyenv ] ; then
-    export PATH="$HOME/.pyenv/bin:$PATH"
-    eval "$(pyenv init -)"
+if [ -d $HOME/.anyenv ] ; then
+    export PATH="$HOME/.anyenv/bin:$PATH"
+    eval "$(anyenv init -)"
 fi

I wish I knew earlier ...

When using tmux (additional note)

--If you don't pass the PATH to shims, it seems that you will see system after starting tmux. ――Therefore, it seems that the following differences are necessary.

 if [ -d ${HOME}/.anyenv ] ; then
     export PATH="$HOME/.anyenv/bin:$PATH"
     eval "$(anyenv init -)"
+    for D in `ls $HOME/.anyenv/envs`
+    do
+        export PATH="$HOME/.anyenv/envs/$D/shims:$PATH"
+    done
+
 fi

reference

-[Troubleshooting that * env / shims is read before system PATH and system is used by anyenv (* env) in tmux](http://monmon.hateblo.jp/entry/2013/12/13 / 233242)

anyenv install

The following is a memo when installing.

Install ** env corresponding to ruby, perl, python, node.js.

$ anyenv install rbenv
$ anyenv install plenv
$ anyenv install pyenv
$ anyenv install ndenv

I think that the initial state points to the system as shown below.

$ anyenv versions
ndenv:
* system (set by /Users/luckypool/.anyenv/envs/ndenv/version)
plenv:
* system (set by /Users/luckypool/.anyenv/envs/plenv/version)
pyenv:
* system (set by /Users/luckypool/.anyenv/envs/pyenv/version)
rbenv:
* system (set by /Users/luckypool/.anyenv/envs/rbenv/version)

So, install from the familiar ** env.

$ rbenv install 2.1.0
$ plenv install 5.16.3
$ ndenv install v0.10.25
$ pyenv install 2.7.6
$ pyenv install 3.3.3

It will take some time for each, but if it is installed properly, it will be as follows.

$ anyenv versions                                                                                     
ndenv:
  system
* v0.10.25 (set by /Users/luckypool/.anyenv/envs/ndenv/version)
plenv:
* system (set by /Users/luckypool/.anyenv/envs/plenv/version)
  5.16.3
pyenv:
* system (set by /Users/luckypool/.anyenv/envs/pyenv/version)
  2.7.6
  3.3.3
rbenv:
* system (set by /Users/luckypool/.anyenv/envs/rbenv/version)
  2.1.0

So, set global to point to the installed version.

rbenv global 2.1.0
plenv global 5.16.3
ndenv global v0.10.25
pyenv global 3.3.3

It has changed!

$ anyenv versions                                                                                     
ndenv:
  system
* v0.10.25 (set by /Users/luckypool/.anyenv/envs/ndenv/version)
plenv:
  system
* 5.16.3 (set by /Users/luckypool/.anyenv/envs/plenv/version)
pyenv:
  system
  2.7.6
* 3.3.3 (set by /Users/luckypool/.anyenv/envs/pyenv/version)
rbenv:
  system
* 2.1.0 (set by /Users/luckypool/.anyenv/envs/rbenv/version)

A cane that won't fall

You can check it if necessary, but it's easy to forget, so check the following as well.

Insert bundler for ruby code.

$ which gem
/Users/luckypool/.anyenv/envs/rbenv/shims/gem
$ gem install bundler
$ which bundle
/Users/luckypool/.anyenv/envs/rbenv/shims/bundle

Put cpanm and carton for perl code.

$ plenv install-cpanm
$ cpanm Carton
$ which carton
$ /Users/luckypool/.anyenv/envs/plenv/shims/carton

Make sure that pip and npm are also in your PATH.

$ which pip
/Users/luckypool/.anyenv/envs/pyenv/shims/pip
$ which npm
/Users/luckypool/.anyenv/envs/ndenv/shims/npm

that's all!

Recommended Posts

Prepare the development environment with anyenv
Install Ubuntu 20.04 with GUI and prepare the development environment
Prepare Python development environment with Atom
Note: Prepare the environment of CmdStanPy with docker
Prepare the execution environment of Python3 with Docker
Build the fastest Django development environment with docker-compose
Prepare python3 environment with Docker
[Day 1] Prepare Django's development environment
Prepare pipenv environment with amazon Linux 2
Prepare Python development environment on Ubuntu
Prepare your first Python development environment
Prepare Python development environment with Mac + Windows + VisualStudio Code (Windows version)
Prepare Python development environment with Mac + Windows + VisualStudio Code (Mac version)
How to get into the python development environment with Vagrant
Checking the NAOqi Python development environment
Rebuild Django's development environment with Docker! !! !! !!
Prepare the environment for Atom for Pythonista
Prepare a distributed load test environment with the Python load test tool Locust
[Development environment] Python with Xcode [With screen transition]
How to prepare Python development environment [Mac]
About the development environment you are using
The strongest Python development environment PyCharm's recommendation
The strongest Python integrated development environment PyCharm
Prepare the environment of Chainer on EC2 spot instance with AWS Lambda
Build a C language development environment with a container
Build Django + NGINX + PostgreSQL development environment with Docker
Build Python development environment with Visual Studio Code
Go (Echo) Go Modules × Build development environment with Docker
Create the strongest calculator environment with Sympy + Jupyter
Instantiation of the BOX development environment created earlier
[Python] Build a Django development environment with Docker
[Blender] Prepare the Blender script debugging environment (Eclipse + PyDev)
Build a Django development environment with Doker Toolbox
Get a quick Python development environment with Poetry
Prepare the development environment for Python on AWS Cloud9 (pip install & time change)
Prepare the environment for O'Reilly's book "Deep Learning from scratch" with apt-get (Debian 8)
Prepare a development environment that is portable and easy to duplicate without polluting the environment with Python embeddable (Windows)
Virtualize (isolate) IBM i python development environment with chroot
Development digest with Django
Repairing a broken development environment with mavericks migration (Note)
The story of sharing the pyenv environment with multiple users
Python development environment construction
Create a python development environment with vagrant + ansible + fabric
Make it easy to install the ROS2 development environment with pip install on Python venv
About Python development environment
Build a machine learning application development environment with Python
Python environment with docker-compose
Python development environment with Windows + Anaconda3 + Visual Studio Code
python2.7 development environment construction
Environment construction with anyenv + pyenv (migrate from pyenv only (Mac))
QGIS3 Python plugin development environment construction with VSCode (macOS)
Manage Python runtime packages and development environment packages with Poetry
Python development environment with Windows + Python + PipEnv + Visual Studio Code
Development environment in Python
How to set the development environment for each project with VSCode + Python extension + Miniconda
Build a development environment with Poetry Django Docker Pycharm
Ssh to virtual environment with remote development of vscode
python memo (for myself): About the development environment virtualenv
[Memo] Django development environment
Virtual environment with Python 3.6
Set up a Python development environment with Sublime Text 2