上一篇 | 这是最后一篇日志下一篇
Python/Django 订阅所有Python/Django的日志

老版本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


除非申明,文章均为一号门原创,转载请注明本文地址,谢谢!
[本日志由 yihaomen 于 2019-06-13 03:26 PM 编辑]
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.