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頭文件夾到相關目錄下

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容