Install the Python Fabric runtime environment in CentOS 6.3

Source: Internet
Author: User

Install the Python Fabric runtime environment in CentOS 6.3

Fabric is always not installed successfully when you install fabric in CentOS6.3, and an error is always thrown when you execute the fab command.
Traceback (most recent call last ):
File "/usr/bin/fab", line 5, in <module>
From pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2655, in <module>
Working_set.require (_ requires __)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
Needed = self. resolve (parse_requirements (requirements ))
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
Raise DistributionNotFound (req)
Pkg_resources.DistributionNotFound: paramiko >=1.10

Solution

Install Python2.7 to replace the default Python2.6, and then install the fabric package.

Centos6.3 the default Python version is 2.6.

1. Download The Python2.7 installation package
Download the 2.7 source code package on the Python official website.
Wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz


2. decompress, compile, and install
Xz-d Python-2.7.8.tar.xz
Tar xvf Python-2.7.8.tar
Cd Python-2.7.8
./Configure -- prefix =/usr/local/python2.7
Make
Make install

3. Create a soft connection to overwrite the default python
Ln-fs/usr/local/python2.7/bin/python2.7/usr/bin/python

The yum of the system depends on python2.6. At this time, the default python version of the system is 2. 7. *. To ensure that yum runs properly, make sure to modify/usr/bin/yum.
Vi/usr/bin/yum

Set the #! Of the first line #! /Usr/bin/python #! /Usr/bin/python2.6

4. Install pip package management tool

Pip is a tool for installing and managing python packages.
Wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
Python get-pip.py
Ln-fs/usr/local/python2.7/bin/pip/usr/bin/pip

5. Install fabric
Pip install fabric
Ln-fs/usr/local/python2.7/bin/fab/usr/bin/fab

Here fabric has been installed and can run properly. After a long time, it has finally been completed .~~~ Installing fabric in Ubuntu saves a lot of trouble.


A code example for executing simple deployment is provided for your reference only.
#-*-Coding: UTF-8 -*
# Add Chinese annotation Encoding
# Fabfile. py
From fabric. api import *

Env. user = 'root'
Env. hosts = ['192. 168.1.100 ']
# Do not enter the remote server password. You would rather enter the password during the running process because it is displayed in plaintext and is not secure.
# You can also connect the ssh of the host to avoid the trouble of entering the password.
# Env. password = 'testtest'

# Retrieve from the version library and delete the. svn File
Def download ():
Local ('rm-rf/tmp/newer ')
Local ('mkdir/tmp/newer ')
Local ('svn checkout svn: // localhost/newer/tmp/newer ')
Local ('Find/tmp/newer-name ". svn" | xargs rm-rf ')

# Compression and packaging
Def pack ():
With LCD ('/tmp /'):
Local ('tar czvf newer.tar.gz./newer ')

# Deploy the remote server directory structure
Def display ():
Run ('rm-rf/var/www/html/tmp ')
Run ('mkdir/var/www/html/tmp ')
# Send a local compressed package to a remote server
Put ('/tmp/newer.tar.gz', '/var/www/html/tmp ')

With cd ('/var/www/html/tmp '):
Run ('tar xvf newer.tar.gz ')

# Special processing of all partial Directories
With cd ('/var/www/html/newer/public /'):
Run ('cp-r ueditor.../../tmp ')

With cd ('/var/www/html /'):
Run ('rm-rf newer ')
Run ('cp-r/var/www/html/tmp/newer ./')

With cd ('/var/www/html/newer/public '):
Run ('rm-rf ueditor ')
Run ('cp-r/var/www/html/tmp/ueditor ./')

# Execute deployment
Def go ():
Download ()
Pack ()
Display ()

Use Vagrant and Fabric for Integration Testing

Fabric: Python Remote Deployment Tool

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.