windows下安装python拓展包

linux和windows下安装python拓展包-pycharm、numpy、scipy、matplotlib、scikit、gensim、PIL、OpenCV、django、pythonqt…

http://blog.csdn.net/pipisorry/article/details/39902327

安装Python集成开发环境IDE

1.安装pycharm IDElinux和windows中搭建python开发环境

2.IPython:方便今后编译其他扩展库,占用空间92.8M:

sudo apt-get install python-dev

IPython

为了安装最新版的IPython 0.13beta,需要下载IPython源代码,并执行安装命令。在IPython 0.13beta中提供了改进版本的IPython notebook。下面的命令首先安装版本管理软件git,然后通过git命令从IPython的开发代码库中下载最新版本的IPython源代码,并执行安装命令:

cd

sudo apt-get install git

git clone https://github.com/ipython/ipython.git

cd ipython

sudo python setup.py install

如果安装目前的最新稳定版本,可以输入:

sudo apt-get install ipython

安装完毕之后,请输入ipython命令测试是否能正常启动。

为了让IPython notebook工作,还还需要安装tornado和pyzmq:

sudo pip install tornado

sudo apt-get install libzmq-dev

sudo pip install pyzmq

sudo pip install pygments

下面测试IPython:

cd

mkdir notebook

cd notebook

ipython notebook

为了在IPython中离线使用LaTeX数学公式,需要安装mathjax,首先输入下面的命令启动ipython notebook:

sudo ipython notebook

在IPython notebook界面中输入:

from IPython.external.mathjax import install_mathjax

install_mathjax()

[http://blog.csdn.net/pipisorry/article/details/39902327]

FOR LINUX:

和Python(x,y)不一样,在Ubuntu中需要手工安装科学计算的各个模块,下面介绍如何在linux下安装NumPy, SciPy, matplotlib, scikit-learn,NLTK,gensim,PIL,OpenCV,PyQt4, Spyder, Cython, SWIG, ETS

在Ubuntu下安装Python模块通常可以使用apt-get和pip命令。

apt-get命令是Ubuntu自带的包管理命令,而pip则是Python安装扩展模块的工具,通常pip会下载扩展模块的源代码并编译安装

Ubuntu 12.04中缺省安装了Python2.7.3,首先通过下面的命令安装pip,pip是Python的一个安装和管理扩展库的工具。[Python的包管理工具]

sudo apt-get install python-pip

Ubuntu 14.04中缺省安装了Python3,自带pip,不用安装。

linux下安装NumPy,SciPy和matplotlib

1. 通过apt-get命令快速安装

sudo apt-get install python-numpy

sudo apt-get install python-scipy

sudo apt-get install python-matplotlib

可以在pycharm console中查看 numpy版本和路径:

import numpy

print numpy.__version__

print numpy.__file__

2. 通过pip编译安装

可以先用apt-get命令安装所有编译所需的库:

sudo apt-get build-dep python-numpy

sudo apt-get build-dep python-scipy

然后通过pip命令安装:

sudo pip install numpy

sudo pip install scipy

通过build-dep会安装很多库,包括Python 3.2。

PyQt4和Spyder

下面的命令安装PyQt4,Qt界面设计器,PyQt4的开发工具以及文档:

sudo apt-get install python-qt4

sudo apt-get install qt4-designer

sudo apt-get install pyqt4-dev-tools

sudo apt-get install python-qt4-doc

安装完毕之后,文档位于:

/usr/share/doc/python-qt4-doc

安装好PyQt4之后通过下面的命令安装Spyder:

sudo apt-get install spyder

由于Spyder经常更新,通过下面的命令可以安装最新版

sudo pip install spyder –upgrade

cython和SWIG

Cython和SWIG是编写Python扩展模块的工具:

sudo pip install cython

sudo apt-get install swig

输入 cython –version 和 swig -version 查看版本。

ETS

ETS是enthought公司开发的一套科学计算软件包,其中的Mayavi通过VTK实现数据的三维可视化。

首先通过下面的命令安装编译ETS所需的库:

sudo apt-get install python-dev libxtst-dev scons python-vtk  pyqt4-dev-tools python2.7-wxgtk2.8 python-configobj

sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev

创建ets目录,并在此目录下下载ets.py,运行ets.py可以复制最新版的ETS源程序,并安装:

mkdir ets

cd ets

wget https://github.com/enthought/ets/raw/master/ets.py

python ets.py clone

sudo python ets.py develop

#sudo python ets.py install    或者运行install安装

如果一切正常,那么输入 mayavi2 命令则会启动mayavi。

linux下安装scikit-learn

Building scikit-learn with pip

This is usually the fastest way to install or upgrade to the latest stablerelease:

pip install –user –install-option=”–prefix=” -U scikit-learn

Note:

1. The–userflag ask pip to install scikit-learn in the$HOME/.localfolder therefore not requiring root permission. This flag should make pipignore any old version of scikit-learn previously installed on the system whilebenefitting from system packages for numpy and scipy. Those dependencies canbe long and complex to build correctly from source.

2. The–install-option=”–prefix=”flag is only required if Python has adistutils.cfgconfiguration with a predefinedprefix=entry.

From source package

Download the source package fromhttp://pypi.python.org/pypi/scikit-learn/, unpack the sources and cd into the source directory.

This packages uses distutils, which is the default way of installingpython modules. The install command is:

python setup.py install

[Installing scikit-learn]

linux下安装NLTK

Install Setuptools:http://pypi.python.org/pypi/setuptools

Install Pip: runsudoeasy_installpip

Install Numpy (optional): runsudopipinstall-Unumpy

Install NLTK: runsudopipinstall-Unltk

Test installation: runpythonthen typeimportnltk

Note:Mac/Unix都通过这种方式安装nltk

[http://www.nltk.org/install.html]

linux下安装gensim

1. #pip install gensim

2.下载gensim-0.10.3.tar_2.gz

unzipped the source tar.gz package, you’ll need to run:

#python setup.py test

#python setup.py install

Note:gensim依赖NumPy和SciPy,要先安装

gensim/install

linux下安装OpenCV

python-opencv:

环境

ubuntu 12.04 LTS

python 2.7.3

opencv 2.3.1-7

安装依赖

sudo apt-get install libopencv-*

sudo apt-get install python-opencv

sudo apt-get install python-numpy

在python中使用OpenCV

python使用opencv进行人脸识别

Ubuntu 12.04下安装OpenCV 2.4.2

UBUNTU下安装OPENCV和测试python-opencv

Ubuntu下Opencv与Python的协作

ubuntu 下 安装 python-opencv 配置

dpkg -L python-opencv命令查看,搜索安装到何处

root@ubuntu:~#dpkg -L python-opencv

/.

/usr

/usr/share

/usr/share/python-support

/usr/share/python-support/python-opencv.public

/usr/share/doc

/usr/share/doc/python-opencv

/usr/share/doc/python-opencv/copyright

/usr/share/pyshared

/usr/share/pyshared/cv.py

/usr/lib

/usr/lib/pyshared

/usr/lib/pyshared/python2.7

/usr/lib/pyshared/python2.7/cv2.so

/usr/share/doc/python-opencv/changelog.Debian.gz

测试opencv安装好没:

view plaincopy to clipboardprint?

####################################   coding=utf-8#   !/usr/bin/env python#   __author__ = ‘pipi’#   ctime 2014.10.12#   测试opencv###################################import cvif __name__ == ‘__main__’:    img = cv.LoadImageM (“faces.jpg”)   # 打开图像    cv.NamedWindow (“ShowImage”)        # 创建窗口    cv.ShowImage (“ShowImage”, img)     # 显示图像    cv.WaitKey (0)

####################################  coding=utf-8#  !/usr/bin/env python#  __author__ = ‘pipi’#  ctime 2014.10.12#  测试opencv###################################import cvif __name__ == ‘__main__’:    img = cv.LoadImageM (“faces.jpg”)  # 打开图像    cv.NamedWindow (“ShowImage”)        # 创建窗口    cv.ShowImage (“ShowImage”, img)    # 显示图像    cv.WaitKey (0)

python-opencv这个基本过时了,cv2是opencv自己带的python绑定,编译opencv应该就有了

python-opencv:

更新下载更新软件包列表信息

apt-get update

查询OpenCV相关软件包

$ apt-cache search opencv

libcv-dev – development files for libcv

libcv1 – computer vision library

libcvaux-dev – development files for libcvaux

libcvaux1 – computer vision extension library

libhighgui-dev – development files for libhighgui

libhighgui1 – computer vision GUI library

opencv-doc – OpenCV documentation and examples

python-opencv – Python bindings for the computer vision library

//以上内容可能是没有及时更新

//用命令行$ apt-cache search opencv在ubuntu(12.04LTS)找到的最新的opencv版本是2.1

harpia – Image Processing/Computer Vision Automatic Prgm. Tool

libcv-dev – development files for libcv

libcv2.1 – computer vision library

libcvaux-dev – development files for libcvaux

libcvaux2.1 – computer vision extension library

libhighgui-dev – development files for libhighgui

libhighgui2.1 – computer vision GUI library

opencv-doc – OpenCV documentation and examples

python-opencv – Python bindings for the computer vision library

在这里,OpenCV的库CxCore和Cv都被包含入Deb包libcv中。

安装相关软件包

如果只是用来运行OpenCV程序,仅需安装libcv1,libcvaux1,libhighgui1:

apt-get install libcv1 libcvaux1 libhighgui1

如果你要使用OpenCV来编写程序,那么还需要安装libcv-dev,libcvaux-dev,libhighgui-dev包。

apt-get install libcv-dev libcvaux-dev libhighgui-dev

文档在opencv-doc包中,python-opencv是OpenCV的Python语言包,可根据需要安装。

测试安装包

测试是否安装成功,你可以使用以下的命令行编译位于源代码包中的drawing.c例子:

g++ drawing.c `pkg-config opencv –libs –cflags opencv` -o drawing

成功编译后你应该能够可以执行./drawing看到highgui输出窗口的结果了.

Debian/Ubuntu下安装

c-opencv?

为了编译OpenCV需要下载cmake编译工具,和一些依赖库:

sudo python setup.py install

sudo apt-get install build-essential

sudo apt-get install cmake

sudo apt-get install cmake-gui

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev

sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libjasper-dev

然后终端输入http://sourceforge.net/projects/opencvlibrary/files/latest/download?source=files下载opencv源代码

或者从http://sourceforge.net/projects/opencvlibrary/下载最新版的OpenCV源代码,并解压。

然后创建编译用的目录release,并启动cmake-gui:

mkdir release

cmake-gui

在界面中选择OpenCV源代码的目录,和编译输出目录release,然后按Configure按钮,并根据需要设置各个编译选项,最后点Generate按钮,退出cmake-gui界面。进入编译路径,执行下面的命令:

cd release

make

sudo make install

安装完毕之后,启动IPython,并输入 import cv2 测试OpenCV是否能正常载入。在Ubuntu下貌似OpenCv不兼容使用apt-get安装numpy和scipy貌似,好像版本过低。我的解决方法是下了最新的numpy和scipy,然后自己编译安装上去的。为了安装这两个软件,我又安装了另外一大堆东西。

ps:在Ubuntu下貌似OpenCv不兼容使用apt-get安装numpy和scipy貌似,版本过低。解决方法是下载最新的numpy和scipy,然后自己编译安装上去的。为了安装这两个软件,还要安装了另外一大堆东西。

[http://blog.csdn.net/pipisorry/article/details/39902327]

for windows

windows下安装NumPy,SciPy,matplotlib,pil, gensim, django,pandas等python拓展包,直接下载exe文件或者whl文件安装(前提已安装python)

windows安装包下载[Unofficial Windows Binaries for Python Extension Packages]

whl文件的安装

1. 安装whl拓展名的包需要pip,安装pip【安装pip】(python3自带,不用安装)

2. 安装whl文件

1>打开python,在python命令行中输入(如果提示install错误,见2>)

pipinstallPillow-2.7.0-cp34-none-win_amd64.whl

2>直接在cmd中输入上面的安装命令

windows下安装PIL

1 win32下安装pil.whl文件

下载http://www.pythonware.com/products/pil/

2 win64下安装pil:

没有pil安装包,可用pillow(里面包含pil)替代,下载pillow.whl安装包安装

windows下安装gensim

Note:gensim依赖NumPy和SciPy

1pip安装:

pip install gensim    #python3自带pip

2  下载原码安装:

https://pypi.python.org/pypi/gensim#downloads

unpack the source  gensim-0.10.3.tar.gz and run

`D:\Downloads\Programming\Python\gensim-0.10.3> python setup.py install`

[scripygensimwindows64 位 安装python 扩展包pythoncollection]

Documentation

Manual for the gensim package is available inHTML. Itcontains a walk-through of all its features and a complete reference section.It is also included in the source distribution package.

[https://pypi.python.org/pypi/gensim#downloads]

pip安装gensim时出现错误:

#【彻底解决 error: Unable to find vcvarsall.bat

1 pip install for python 2.7:

C:\Users\pi\pip\pip.log:

Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it fromhttp://aka.ms/vcpython27

an integer is required

解释:For Windows installations:

While running setup.py for package installations, Python 2.7 searches for an installed Visual Studio 2008. You can trick Python to use a newer Visual Studio by setting the correct path inVS90COMNTOOLSenvironment variable before callingsetup.py.

Execute the following command based on the version of Visual Studio installed:

Visual Studio 2010 (VS10): SET VS90COMNTOOLS=%VS100COMNTOOLS%

Visual Studio 2012 (VS11): SET VS90COMNTOOLS=%VS110COMNTOOLS%

Visual Studio 2013 (VS12): SET VS90COMNTOOLS=%VS120COMNTOOLS%

【http://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat?rq=1

Installing gensim in windows 7

2pip install forpython3.4:

TypeError: ‘str’ object cannot be interpreted as an integer

Unable to find vcvarsall.bat

‘str’ object cannot be interpreted as an integer

解决:只安装visual studio 2010中c++就ok了

Important Note:【http://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat?rq=1

If you are using a Python versionmore recentthan Python 2.7 (especially any Python 3.x), you most likely need a version of Visual Studio C++other thanthe 2008 version.

See bottom for details.

Installing Windows SDK 7.1 and then re-installing MS 2010 C++ Express Edition fixed the problem.

【https://groups.google.com/forum/#!msg/gensim/8Qe-nlBMncU/4Kl0zh4ZtuoJ

python在windows下通过pip安装带有c扩展的包时,如果是python 2.7,需要vs2008,如果是python 3.x,需要vs2010,版本错了都不行,更别提mingw。因为c运行时不兼容的原因。

http://www.zhihu.com/question/26857761

3Difficulty installing Gensim using from source and pip

[http://blog.csdn.net/pipisorry/article/details/39902327]

windows下pythonQt的安装和使用

Test installation测试python拓展安装包是否安装成功

运行python

然后import×××,没有提示错误就说明安装成功

from:http://blog.csdn.net/pipisorry/article/details/39902327

ref:Ubuntu中安装Python科学计算环境

Ubuntu-Python2.7安装 scipy,numpy,matplotlib

Mountail Lion 上的 Python 科研环境的搭建

    原文作者:hzyido
    原文地址: https://www.jianshu.com/p/022a57498fee
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞