zoukankan      html  css  js  c++  java
  • python 相关安装和配置

    永久链接: http://michaelzqm.iteye.com/blog/1841966

    预览文章: python环境搭建 编辑 删除

    2013-04-04
    博客分类:
     

    一. window环境安装

    1. 安装python 2.7.3 (win7 64)

    下载python-2.7.3.amd64.msi

    2. 安装easy_install

    3. 安装其他功能包

    如:easy_install MySQL-python

    easy_install -U DBUtils

    问题解决:

    .没有gcc编译环境

    unable to find vcvarsall.bat

    解决方法:安装编译环境(一个老外的帖子)

    1)  First ofall download MinGW. Youneed g++compiler and MingW make in setup.

    2)  If youinstalled MinGW for example to “C:MinGW” then add “C:MinGWin”to your PATH in Windows.(安装路径加入环境变量)

    3)  Now startyour Command Prompt and go the directory where you have your setup.py residing.

    4)  Last andmost important step:

    setup.py install build --compiler=mingw32

    或者在setup.cfg中加入:
    [build]
        compiler = mingw32

    4. 已编译版本安装

    MySQL-python-1.2.3.win-amd64-py2.7.exe

    5. api文档地址 2.7

    http://docs.python.org/2/py-modindex.html

    二. linux环境

     1.  下载DBUtils1.1
     wget http://www.webwareforpython.org/downloads/DBUtils/DBUtils-1.1.tar.gz

     2. 解压
     tar -xvf DBUtils-1.1.tar.gz 

     3. 安装DBUtils1.1
     cd DBUtils-1.1
     python setup.py install

     4. 安装MySQL-python
     yum install MySQL-python

    5. 安装pip

    yum install python-pip

    检查

    which pip-python

    三. 数据挖掘环境

    安装activepython,自带了easy_install

    easy_install numpy

    easy_install networkx

    easy_install twitter

    easy_install nltk

    easy_install BeautifulSoup

    四. 安装pil

    windows64位

    下载Pillow-2.0.0.win-amd64-py2.7.exe

    下载地址:http://www.lfd.uci.edu/~gohlke/pythonlibs/

    导入

    windows用:from PIL import Image

    linux用:import Image

    centos 64位

    wget "http://effbot.org/downloads/Imaging-1.1.7.tar.gz"

    tar xvfz Imaging-1.1.7.tar.gz

    cd Imaging-1.1.7

    python setup.py build_ext -i

    如果出错:command 'gcc' failed with exit status 1,需要安装python一个插件

    yum install python-devel

    如果使用pil时出错:decoder jpeg not available,则安装jpeg库

    yum install libjpeg-devel

    下载FREETYPE2

    wget "http://sourceforge.net/projects/freetype/files/freetype2/2.4.8/freetype-2.4.8.tar.gz"

    tar zxvf freetype-2.4.8.tar.gz 

    cd freetype-2.4.8

    make

    make install

    安装png库

    yum install zlib zlib-devel

    重新安装

    python setup.py build_ext -i

    python setup.py install

    使用:

    import sys
    sys.path.append("/root/Imaging-1.1.7/PIL")
    import Image

    五. 安装python magick

    window安装

    1. 下载imagemagick并安装

    http://www.imagemagick.org/script/binary-releases.php#windows

    2. 安装wand

    easy_install Wand

    3. 示例代码

    #!/usr/bin/env python
    from urllib2 import urlopen
    from wand.image import Image

    def dowloadImg(url):
        f = urlopen(url);
        return Image(file=f);

    def resizeImg(img, width, height):
        print img.size
        img.resize(width, height)
        img.save(filename = 'temp_%s_%s.%s' % (img.width, img.height, img.format))

    if __name__ == '__main__':
        img = dowloadImg('http://xxx.com/xxx.png')
        resizeImg(img,64,64)
        resizeImg(img,48,48)

     centos

    1. 安装imagemagick

    yum update

    yum  install  ImageMagick-devel

    2. 安装 Wand

    pip-python install Wand

  • 相关阅读:
    iOS真机调试 for Xcode 5
    iOS/iphone开发如何为苹果开发者帐号APPID续费
    unity3d中布娃娃系统
    U3D实现与iOS交互
    两种方法连接MySql数据库
    Unity3D Gamecenter 得分上传失败的处理
    Unity3.5 GameCenter基础教程(转载)
    判断数字正则表达式
    (转)SQL server 2005查询数据库表的数量和表的数据量
    C#操作PowerDesigner代码
  • 原文地址:https://www.cnblogs.com/lhj588/p/3358789.html
Copyright © 2011-2022 走看看