I heard that it is easy to build a Python environment using direnv, so I created a 3rd system environment on Ubuntu. It's from putting the Ubuntu 14.04 box in Vagrant.
Get a box
vagrant box add ubuntu-14.04 https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box
vagrant init ubuntu-14.04
vagrant up
Log in to vagrant
vagrant ssh
Package update
sudo apt-get update
Install pip and pythonz.
Install pip and pythonz
sudo apt-get install build-essential zlib1g-dev libbz2-dev libssl-dev libreadline-dev libncurses5-dev libsqlite3-dev libgdbm-dev libdb-dev libexpat-dev libpcap-dev liblzma-dev libpcre3-dev curl python-pip
curl -kL https://raw.github.com/saghul/pythonz/master/pythonz-install | bash
echo '[[ -s $HOME/.pythonz/etc/bashrc ]] && source $HOME/.pythonz/etc/bashrc' >> $HOME/.bashrc
exec $SHELL
sudo pip install virtualenv
Downloading/unpacking virtualenv
  Downloading virtualenv-13.1.2-py2.py3-none-any.whl (1.7MB): 1.7MB downloaded
Installing collected packages: virtualenv
Successfully installed virtualenv
Cleaning up...
curl -L -o direnv https://github.com/zimbatm/direnv/releases/download/v2.5.0/direnv.linux-amd64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   142    0   142    0     0     22      0 --:--:--  0:00:06 --:--:--    37
  0     0    0   602    0     0     93      0 --:--:--  0:00:06 --:--:--    93
100 3579k  100 3579k    0     0   236k      0  0:00:15  0:00:15 --:--:--  865k
sudo install direnv /usr/local/bin
echo 'type direnv > /dev/null 2>&1 && eval "$(direnv hook bash)" ' >> $HOME/.bashrc
exec $SHELL
pythonz list -a
Abbreviation
     2.7.8
     2.7.9
     2.7.10
     3.0
     3.0.1
     3.1
Abbreviation
It seems that 2.7.6 series is included by default.
python -V
Python 2.7.6
pythonz install 3.4.3
Downloading Python-3.4.3.tgz as /home/vagrant/.pythonz/dists/Python-3.4.3.tgz
########################################################################## 100%
Extracting Python-3.4.3.tgz into /home/vagrant/.pythonz/build/CPython-3.4.3
This could take a while. You can run the following command on another shell to track the status:
  tail -f /home/vagrant/.pythonz/log/build.log
Installing CPython-3.4.3 into /home/vagrant/.pythonz/pythons/CPython-3.4.3
Installed CPython-3.4.3 successfully.
pythonz locate 3.4.3
/home/vagrant/.pythonz/pythons/CPython-3.4.3/bin/python3
pip -V
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
pwd
/home/vagrant
Make python3.4.3 available in the directory / home / vagrant / sand_box.
sand_Set to use python in box directory
echo 'layout python $(pythonz locate 3.4.3)' > sand_box/.envrc
direnv allow sand_box
exit
vagrant ssh
Maybe you don't need this logout procedure?
If you move to the directory sand_box here, the installation will start automatically.
cd sand_box
direnv: loading .envrc
Running virtualenv with interpreter /home/vagrant/.pythonz/pythons/CPython-3.4.3/bin/python3
Using base prefix '/home/vagrant/.pythonz/pythons/CPython-3.4.3'
New python executable in /home/vagrant/sand_box/.direnv/python-3.4.3/bin/python3
Also creating executable in /home/vagrant/sand_box/.direnv/python-3.4.3/bin/python
Installing setuptools, pip, wheel...done.
direnv: export +VIRTUAL_ENV ~PATH
pip install PrettyTable
Collecting PrettyTable
  Downloading prettytable-0.7.2.tar.bz2
Building wheels for collected packages: PrettyTable
  Running setup.py bdist_wheel for PrettyTable
  Stored in directory: /home/vagrant/.cache/pip/wheels/41/46/ec/ec86e65e50e9f4be52547a3bedd46077e7414c53d2ed0418fd
Successfully built PrettyTable
Installing collected packages: PrettyTable
Successfully installed PrettyTable-0.7.2
I entered normally. If pip isn't called correctly via 3.4.3, it won't work.
python -V
Python 3.4.3
I created a directory called / var / www / sand_box and put other versions of Python in it.
sudo mkdir /var/www
sudo chown vagrant:vagrant /var/www
Before moving to the directory, it is Python2 series.
python -V
Python 2.7.6
pythonz install 3.2.4
Downloading Python-3.2.4.tgz as /home/vagrant/.pythonz/dists/Python-3.2.4.tgz
########################################################################## 100%
Extracting Python-3.2.4.tgz into /home/vagrant/.pythonz/build/CPython-3.2.4
This could take a while. You can run the following command on another shell to track the status:
  tail -f /home/vagrant/.pythonz/log/build.log
Installing CPython-3.2.4 into /home/vagrant/.pythonz/pythons/CPython-3.2.4
Installed CPython-3.2.4 successfully.
mkdir sand_box
If you go to / var / www / sand_box, the 3.2.4 series files will be installed.
cd sand_box/
direnv: loading .envrc
Running virtualenv with interpreter /home/vagrant/.pythonz/pythons/CPython-3.2.4/bin/python3
New python executable in /var/www/sand_box/.direnv/python-3.2.4/bin/python3
Also creating executable in /var/www/sand_box/.direnv/python-3.2.4/bin/python
Installing setuptools, pip, wheel...done.
direnv: export +VIRTUAL_ENV ~PATH
pip install PrettyTable
Collecting PrettyTable
Installing collected packages: PrettyTable
Successfully installed PrettyTable-0.7.2
There were various reference sites, but I didn't make a note. \ (^ O ^) / http://qiita.com/jnotoya/items/ca9a0dfee6b9f084f4da
Recommended Posts