python学习之--ubuntu下 如何安装第三方库的简要方法

来源:互联网 发布:阿里数据平台有哪些 编辑:程序博客网 时间:2024/05/22 04:26

ubuntu下python安装第三方库(library)的简易方法


安装个easy_install工具
sudo apt-get install python-setuptools
然后sudo就OK了

比如Ubuntu下Python读写excel库

sudo easy_install xlrd

sudo easy_install xlwt

sudo easy_install xlutils

使用:

import xlrd

import xlwt

import xlutils


有时候执行 easy_install xxx(module名字)后可能会出现如下打印:


yanglan@yanglan-pc:~$ sudo easy_install media
[sudo] password for yanglan: 
error: can't create or remove files in install directory


The following error occurred while trying to add or remove files in the
installation directory:


    [Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/test-easy-install-15927.write-test'


The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:


    /usr/local/lib/python2.7/dist-packages/


This directory does not currently exist.  Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).


这个可能是因为从来未添加过第三方库,也就是不存在dist-packages目录, 创建一个之后 再执行命令即可.


此时在编辑器中调用media库中的choose_file()方法时,运行时编译器并不识别,查看media库源码发现并没有次方法,我下载的media库版本是:1.0.3 不清楚原因

方法二:

想要操作图片,音频等文件需要下载第三方库:PyGraphics,此库需要一些依赖关系,可参考此处:http://packages.python.org/PyGraphics/install.html



0 0
原创粉丝点击