ubuntu 14.04 执行python问题

问题1
执行.py文件时,因为要处理excel,所以需要用到xlrd模块,从网上下一个xlrd,install时,出现如下问题:

root@ps-IS-200N:/home/ps/xlrd-1.0.0# python2.7 setup.py install
running install
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-4552.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文件所在目录,复制整个python2.7 到/usr/local/lib/目录下

cp -r /usr/lib/python2.7 /usr/local/lib/.

问题2:

ImportError: No module named setuptools

解决方法:

wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar zxvf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11s
python setup.py install

问题3
另外,因为要用到ip相关的处理,在.py文件中引入 ***from netaddr import ****,编译时又出现如下错误:

ImportError: No module named netaddr

解决方法:
下载安装netaddr。下载路径如下:

wget https://pypi.python.org/packages/0c/13/7cbb180b52201c07c796243eeff4c256b053656da5cfe3916c3f5b57b3a0/netaddr-0.7.19.tar.gz

问题4:

问题5:
链接python库时,遇到如下提示:
/usr/bin/ld: cannot find -lpython2.7
解决方法:

apt-get install libpython2.7-dev

在执行上述命令的时候,又遇到以下问题:
Some packages could not be authenticated
解决方法:

apt-get install debian-archive-keyring
apt-get update

问题6:
编译makefile时,提示python.h不存在;
解决方法:
复制完整python2.7头文件夹到相关目录下

你可能感兴趣的:(ubuntu 14.04 执行python问题)