永久链接: 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:\MinGW\bin”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

python 相关安装和配置的更多相关文章

  1. Python 的安装与配置(Windows)

    Python2.7安装配置 python的官网地址:https://www.python.org/ 我这里下载的是python2.7.12版本的 下载后点击安装文件,直接点击下一步知道finally完 ...

  2. Linux下Openfire相关安装和配置

    记录下来,方便下次再用时从头查找资料 小京东ecshop中的通讯有用到openfire,Window下配置安装很简单,直接下载exe文件安装就行,而linux下要麻烦一点.安装后的配置下面会细说: 一 ...

  3. Python的安装和配置(windowns 双版本)

    1.去官网上下载python,注意版本. 官网地址:https://www.python.org/downloads/windows 2.下载安装版或者zip包都可以.安装就按向导一步一步完成即可.z ...

  4. python环境安装及配置

    一.下载python,可选择python2.x或python 3.0 下载地址:[官网],选择系统 ---选择对应版本 注意自己电脑是32位(X86)还是64位(x86-64) 下载文件包,点击点击安 ...

  5. Robot Framework+python的安装,配置,环境搭建(纯白篇)

    弄了大半天 终于把-Robot Framework-弄好了,总是一个发现问题,一个一个去解决的过程,只是时间嘛,咳咳咳咳 言归正传 第一. 记住了 Robot Framework 的库 只支持 pyt ...

  6. 【python】Python的安装和配置

    Python是一种计算机程序设计语言.是一种动态的.面向对象的脚本语言,最初被设计用于编写自动化脚本(shell),随着版本的不断更新和语言新功能的添加,越来越多被用于独立的.大型项目的开发. Pyt ...

  7. 关于python如何安装和配置chromedriver以及一些相关问题

    解决问题三部曲:观察,思考,尝试 1.如何配置chromedriver: https://www.cnblogs.com/lintest/p/11697059.html 常见异常解决的一个参考吧:ht ...

  8. Windows下php,mysql,apache相关安装与配置,完善中…

    PHP 的安装 由于php是一个zip文件(非install版),安装较为简单解压就行.把解压的 php5.2.1-Win32重命名为 php5.并复制到安装盘目录下.例如安装路径为 c:\php5 ...

  9. python的安装与配置

    pyhton的下载与安装 1.python官网地址:https://www.python.org 2.下载 Python 编辑器PyCharm PyCharm 是一款功能强大的 Python 编辑器 ...

随机推荐

  1. Git平台使用时的配置分析

    Git仓库的配制文件分为三个部分: 1. .git/config:指定仓库配置(特定于某个仓库),获取或设置时使用--file参数(或者省去). 2. ~/.gitconfig:用户级别仓库配置(适用 ...

  2. marquee标签属性详解(跑马灯文字效果)

    请大家先看下面这段代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: ...

  3. 鼠标模拟点击a标签

    今天写程序遇到的,想要用鼠标模拟点击a标签 html代码如下: <a id="jump"></a> js代码如下: var page = ....; $(' ...

  4. java开发中的一些工具软件

    1. XJad, 反编译工具,类似于.Net中的Refractor.可以反编译单个jar文件或一个文件夹下的class文件,效果还不错. 2. dirtyJOE, class文件直接修改工具.有时想修 ...

  5. jsp_设置错误页

    在各个常用的web站点中,当一个页面出错后,会自动跳转到一个页面上进行错误信息的显示.下面我们说说这个操作是怎么实现的. 要想完成错误页的操作,在jsp页面必须满足两个条件: (1)指定错误出现时的跳 ...

  6. asp.net写验证码

    生成验证码与匹配验证码的服务端代码 <%@ WebHandler Language="C#" Class="ValidataeCodeHandler" % ...

  7. Android的项目不能直接引用可移植类库的项目解决方法

    深圳_exception() 10:25:51 Android的项目不能直接引用可移植类库的项目,但是可以引用可移植类库生成的dll,这就意味着无法直接断电调试可移植类库上海-黄药师() 10:26: ...

  8. FileOutputStream保存文件

    //保存文件,根据传入的路径,存放在SD卡目录下public boolean saveToPath(String title, String pageName) { Bitmap b = getCha ...

  9. c++中关于static关键字的问题

    C++的static关键字C++的static有两种用法:面向过程程序设计中的static和面向对象程序设计中的static.前者应用于普通变量和函数,不涉及类:后者主要说明static在类中的作用. ...

  10. httpd 虚拟主机建立之访问机制及其日志定义

    注:关闭防火墙,selinux VirtualHost定义: 基于IP地址VirtualHost: 编辑httpd.conf文件: #DocumentRoot "/web/html" ...