Drip recording--centos 6.4 using virtualenv to install Swift

Source: Internet
Author: User
Tags virtual environment virtualenv

Reprint please indicate source: http://blog.csdn.net/cywosp/article/details/42150141


Brief Introduction
In the development process, a variety of third-party libraries are often required, and Python provides tools such as Pip,easy_install to simplify the installation of the library, so it is easy to fill the system Python site-packages directory with a variety of libraries, However, there are a few things that can be problematic in the following situations:
1. No write access to the Site-packages directory, such as a shared host
2. Different projects rely on different versions of the same library, and these two versions are not backwards compatible
3. When updating the system under Linux, some dependent libraries are automatically updated
solve
At this point we need a tool that we can create our own Python environment to meet the following conditions:
1. We can specify the location of the environment, so that it can be installed in their own privileged directory
2. You can create multiple environments so that different projects can use different environments, even if they depend on different versions of the same library
3. When the system updates automatically, the update of the Site-packages library in the system Python will not affect its own project.
Virtualenv is a tool that creates a python environment in a specified location that has a standalone installation directory that does not share modules with other virtualenv environments. Its specific usage can be referred to https://virtualenv-chinese-docs.readthedocs.org/en/latest/, and the use of virtualenv to create an independent environment has an advantage, It can be combined with PIP to quickly create a project environment.
# Export all third-party libraries in the current environment
Pip Freeze > Requirements.txt
# Install third-party libraries in all files in a new environment
Pip Install-r requirements.txt
Create a virtual environment and install Swift
# Install with root user rights
1. Install virtualenvwrapper来管理虚拟环境 First   easy_install virtualenvwrapper   # 如果没有easy_install,请先安装
  关于 virtualenvwrapperThe use
List Virtual Environments
Workon

You can also use
Lsvirtualenv

Create a new virtual environment
mkvirtualenv [Virtual Environment name]

Start/Switch Virtual environments
Workon [Virtual Environment name]

Deleting a virtual environment
rmvirtualenv [Virtual Environment name]

Leave the virtual environment
Deactivate

2.在~/.bashrc中添加行:source /usr/bin/virtualenvwrapper.sh
Source ~/.bashrc #这一步也可省略, added here for ease of operation in the future, do not have to be executed every time source /usr/bin/virtualenvwrapper.sh

3. Create a virtual environment to install Swift
mkvirtualenv Swift
# The Swift directory will be in ~/.virtualenvs with the following directory structure:.
├──bin
├──include
├──lib
└──lib64, Lib

4. Installation related Dependencies
Yum Updateyum Install Curl gcc memcached rsync sqlite xfsprogs git-core     libffi-devel xinetd python-devel python-paste- Deploy Python-dns

5. Switch to Workon Swift in the SWIFT environment and install the Python-related packages
Easy_install pip
pip install setuptools coverage cffi Simplejson xattr eventlet greenlet netifaces mock PBR

6. Download the Swift source code and install
git clone https://github.com/openstack/swift.git CD Swift pip Install-r requirements.txt python setup.py install--record=file.txt
7. Configure Swift
The configuration of Swift is the same as the normal installation configuration, so this omission

8. Other
When starting swift, be sure to switch to the swift virtual environment, Workeon Swift

There was a small problem with the version after the Python 2.6 version of Swift 2.2.1, details: https://bugs.launchpad.net/swift/+bug/1403430


Reference:
[1]. http://www.iitshare.com/virtualenv-isolate-python-env.html
[2]. https://github.com/lzjun567/note/blob/master/note/python/virtualenv.md

Drip recording--centos 6.4 using virtualenv to install Swift

Related Article

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.