Build a Python 2.7.6 Environment

Source: Internet
Author: User

Build a Python 2.7.6 Environment

Why do I write a script?

Every time you use a new machine, you must install the python environment ~ So, this is a very tricky problem. shell practiced handwriting a code, hey, slag technology ~

Test Environment

I love vagrant. A command can be directly restored to a clean test environment ~

The script is as follows:


#! /Bin/bash

# Auther: zhuima

# Date: 2014-06-26

# Function: create python env

#

 

 

REVTAL = 0

 

# Import Functions

 

./Etc/rc. d/init. d/functions

 

# Check network

 

./Etc/sysconfig/network

 

If [$ NETWORKING = 'no']; then

Exit $ REVTAL

Fi

 

# Install epel yum source

 

Function epel_install (){

If rpm -- version &>/dev/null; then

Rpm-ivh http://mirrors.ustc.edu.cn/Fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

Else

Exit $ REVTAL

Print "please checking your yum configure! "

Fi

}

 

 

# Install base packages

 

Function base_packages (){

If yum repolist &>/dev/null; then

Yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel patch-y

Else

Exit $ REVTAL

Print "please checking your yum configure! "

Fi

}

 

 

# Install pip

 

Function pip_install (){

If yum repolist &>/dev/null; then

Yum install python-pip-y

Else

Exit $ REVTAL

Print "please checking your yum configure! "

Fi

}

 

# Install ipython

 

Function ipython_install (){

If yum repolist &>/dev/null; then

Yum install ipython-y

Else

Exit $ REVTAL

Print "please checking your yum configure! "

Fi

}

 

# Install pyenv

 

Function pyenv_install (){

If git -- version &>/dev/null; then

Cd/'whoam' & git clone git: // github.com/yyuu/pyenv.git. pyenv

Else

Yum install git-y

Cd/'whoam' & git clone git: // github.com/yyuu/pyenv.git. pyenv

Fi

}

 

# Setting pyenv env

 

Function pyenv_env (){

 

Echo 'export PYENV_ROOT = $ HOME/. pyenv'>/etc/profile

Echo 'export PATH = $ PYENV_ROOT/bin: $ path'>/etc/profile

# Echo 'eval $ (pyenv init-) '>/etc/profile

 

# Exec pyenv. sh

If [-e/etc/profile]; then

Source/etc/profile

Else

Echo "Files is not exists"

Exit $ REVTAL

Fi

 

}

 

# Install python 2.7.6

 

Function python_install (){

If pyenv versions &>/dev/null; then

Pyenv install 2.7.6

Else

Exit $ REVTAL

Print "please checking your pyenv configure"

Fi

}

 

# Install ansible

 

Function install_ansible (){

If pip -- version &>/dev/null; then

Pip install ansible

Else

Yum install pip-y

Pip install ansible

Fi

 

}

 

While:; do

Cat <EOF

+ ------------------------------------------- +

| 1. Install epel_install |

| 2. Install base_packages |

| 3. Install pip_install |

| 4. Install ipython_install |

| 5. Install pyenv_install |

| 6. Install pyenv_env |

| 7. Install python2.7.6 _ install |

| 8. One-Click Setup |

| 9. [Q | q | quit] to quit |

+ ------------------------------------------- +

EOF

 

Read-p "select which one packages you want to install:" choice

 

Case $ choice in

1)

Epel_install

;;

2)

Base_packages

;;

3)

Pip_install

;;

4)

Ipython_install

;;

5)

Pyenv_install

;;

6)

Pyenv_env

;;

7)

Python2.7.6 _ install

;;

8)

Epel_install

Base_packages

Pip_install

Ipython_install

Pyenv_install

Pyenv_env

Python_install

Source/etc/profile

;;

Q | q | quit)

Exit $ REVTAL

;;

*)

Echo "Usage: select one number (1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 )"

Exit $ REVTAL

;;

Esac

Done

For more details, please continue to read the highlights on the next page:

 

Python core programming version 2. (Wesley J. Chun). [Chinese version of hd pdf]

Python development technology details. (Zhou Wei, Zong Jie). [hd PDF scan version + book guide video + code]

Obtain Linux information using a Python script

Build a desktop algorithm transaction research environment using Python in Ubuntu

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.