老版本python2.6安装pip,psutil 报错问题。

今天在centos服务器上想做一个监控的小程序,首先想到的是用python来写这个小程序,服务器上的python版本很老,暂时没想升级。发现没有 psutil, 所以就像用这个三方的库。结果发现pip也没安装。好吧。一切从头开始.

一, 先安装setuptools.

wget --no-check-certificat  https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
tar zxf setuptools-2.0.tar.gz
cd setuptools-2.0
python setup.py install

二,安装pip
wget https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz --no-check-certificate
tar -xzvf pip-1.3.1.tar.gz
cd pip-1.3.1
python setup.py install

三, 安装python-devel
yum install python-devel

如果不安装这个,在安装psutil的时候可能报错
Downloading/unpacking psutil
  Downloading psutil-5.6.3.tar.gz (435kB): 435kB downloaded
  Running setup.py egg_info for package psutil
    /usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
Installing collected packages: psutil
  Running setup.py install for psutil
    /usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
    building 'psutil._psutil_linux' extension
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=563 -DPSUTIL_LINUX=1 -I/usr/include/python2.6 -c psutil/_psutil_common.c -o build/temp.linux-x86_64-2.6/psutil/_psutil_common.o
    psutil/_psutil_common.c:9:20: error: Python.h: No such file or directory



四. 安装 psutil
pip install psutil


安装成功
Downloading/unpacking psutil
  Running setup.py egg_info for package psutil
    /usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
Installing collected packages: psutil
  Running setup.py install for psutil
    /usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
    building 'psutil._psutil_linux' extension
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=563 -DPSUTIL_LINUX=1 -I/usr/include/python2.6 -c psutil/_psutil_common.c -o build/temp.linux-x86_64-2.6/psutil/_psutil_common.o
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=563 -DPSUTIL_LINUX=1 -I/usr/include/python2.6 -c psutil/_psutil_posix.c -o build/temp.linux-x86_64-2.6/psutil/_psutil_posix.o
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=563 -DPSUTIL_LINUX=1 -I/usr/include/python2.6 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.6/psutil/_psutil_linux.o
    psutil/_psutil_linux.c: In function ‘psutil_disk_partitions’:
    psutil/_psutil_linux.c:215: warning: passing argument 2 of ‘PyErr_SetFromErrnoWithFilename’ discards qualifiers from pointer target type
    /usr/include/python2.6/pyerrors.h:188: note: expected ‘char *’ but argument is of type ‘const char *’
    psutil/_psutil_linux.c: In function ‘psutil_proc_cpu_affinity_set’:
    psutil/_psutil_linux.c:446: warning: suggest explicit braces to avoid ambiguous ‘else’
    psutil/_psutil_linux.c: In function ‘init_psutil_linux’:
    psutil/_psutil_linux.c:670: warning: unused variable ‘v’
    gcc -pthread -shared build/temp.linux-x86_64-2.6/psutil/_psutil_common.o build/temp.linux-x86_64-2.6/psutil/_psutil_posix.o build/temp.linux-x86_64-2.6/psutil/_psutil_linux.o -L/usr/lib64 -lpython2.6 -o build/lib.linux-x86_64-2.6/psutil/_psutil_linux.so
    building 'psutil._psutil_posix' extension
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=563 -DPSUTIL_LINUX=1 -I/usr/include/python2.6 -c psutil/_psutil_common.c -o build/temp.linux-x86_64-2.6/psutil/_psutil_common.o
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=563 -DPSUTIL_LINUX=1 -I/usr/include/python2.6 -c psutil/_psutil_posix.c -o build/temp.linux-x86_64-2.6/psutil/_psutil_posix.o
    gcc -pthread -shared build/temp.linux-x86_64-2.6/psutil/_psutil_common.o build/temp.linux-x86_64-2.6/psutil/_psutil_posix.o -L/usr/lib64 -lpython2.6 -o build/lib.linux-x86_64-2.6/psutil/_psutil_posix.so
    SyntaxError: ('invalid syntax', ('/usr/lib64/python2.6/site-packages/psutil/tests/test_posix.py', 61, 29, "        fmt_map = {'command', 'comm',\n"))
    
Successfully installed psutil

上一篇: [转]Redis配置注意事项
下一篇: tornado热加载框架
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章来源于互联网, 若有侵权, 联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布文章.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号