Python有两个著名的包管理工具easy_install.py和pip。在Python2.7的安装包中,easy_install.py是默认安装的,而pip需要我们手动安装。

在此进行编译安装pip管理工具,下载地址:https://pypi.org/project/pip/#files

现在的pip版本是pip-10.0.1,支持python2.x和python3.x

1、下载文件,然后解压

tar -xf pip-10.0..tar.gz 

2、查看pip文件内容

 [root@python pip-10.0.]# ls
AUTHORS.txt dist LICENSE.txt NEWS.rst pyproject.toml setup.cfg src
build docs MANIFEST.in PKG-INFO README.rst setup.py

3、安装pip

[root@python pip-10.0.]# python setup.py install

4、查看pip安装成功版本

 [root@python pip-10.0.]# pip -V
pip 10.0. from /usr/lib/python2./site-packages/pip-10.0.-py2..egg/pip (python 2.7)

5、测试安装psutil模块

[root@python ~]# pip install psutil

出现以下问题

 Collecting psutil
Downloading https://files.pythonhosted.org/packages/51/9e/0f8f5423ce28c9109807024f7bdde776ed0b1161de20b408875de7e030c3/psutil-5.4.6.tar.gz (418kB)
% |████████████████████████████████| 419kB 227kB/s
ipaclient 4.5. requires jinja2, which is not installed.
rtslib-fb 2.1. has requirement pyudev>=0.16., but you'll have pyudev 0.15 which is incompatible.
ipapython 4.5. has requirement dnspython>=1.15, but you'll have dnspython 1.12.0 which is incompatible.
Installing collected packages: psutil
Running setup.py install for psutil ... error
Complete output from command /bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-BO0YvS/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-FbEPxr/install-record.txt --single-version-externally-managed --compile:
/usr/lib64/python2./distutils/dist.py:: UserWarning: Unknown distribution option: 'python_requires'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/psutil
copying psutil/_exceptions.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psaix.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/__init__.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutil
creating build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/__main__.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_memory_leaks.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_connections.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_system.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/__init__.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_process.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-2.7/psutil/tests
copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-2.7/psutil/tests
running build_ext
building 'psutil._psutil_linux' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/psutil
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE= -fexceptions -fstack-protector-strong --param=ssp-buffer-size= -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE= -fexceptions -fstack-protector-strong --param=ssp-buffer-size= -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX= -DPSUTIL_VERSION= -DPSUTIL_LINUX= -I/usr/include/python2. -c psutil/_psutil_common.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_common.o
psutil/_psutil_common.c:9:20: 致命错误:Python.h:没有那个文件或目录
#include <Python.h>
^
编译中断。
error: command 'gcc' failed with exit status 1 ----------------------------------------
Command "/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-BO0YvS/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-FbEPxr/install-record.txt --single-version-externally-managed --compile" failed with error code in /tmp/pip-install-BO0YvS/psutil/

解决方法:

安装python-devel,这是python的头文件和静态库包

[root@python ~]# yum install python-devel

6、再次安装psutil模块

 [root@python ~]# pip install psutil
Collecting psutil
Using cached https://files.pythonhosted.org/packages/51/9e/0f8f5423ce28c9109807024f7bdde776ed0b1161de20b408875de7e030c3/psutil-5.4.6.tar.gz
ipaclient 4.5. requires jinja2, which is not installed.
rtslib-fb 2.1. has requirement pyudev>=0.16., but you'll have pyudev 0.15 which is incompatible.
ipapython 4.5. has requirement dnspython>=1.15, but you'll have dnspython 1.12.0 which is incompatible.
Installing collected packages: psutil
Running setup.py install for psutil ... done
Successfully installed psutil-5.4.

致此,pip安装成功,可以安装自已想要的模块,解决模块的依赖关系。

最新文章

  1. linux journel
  2. shell学习之路:流程控制(while)
  3. candence 知识积累3
  4. 小结getBytes()默认编码导致的xml字符串中出现乱码
  5. samba linux windows 请联系管理员
  6. strus2与spring3 mvc的差别
  7. Python学习笔记:07异常
  8. oldboy第五天学习
  9. jquery图片滚动仿QQ商城带左右按钮控制焦点图片切换滚动
  10. 信号处理——傅里叶变换(FT-DTFT-DFT)
  11. 【渗透课程】前言-揭开Web渗透与安全的面纱(必看)
  12. MySQL管理员珍藏:十大必备工具盘点
  13. Java Web高级编程(一)
  14. 初识LINUX之常见命令
  15. Python世界里的赋值运算符
  16. 致备战noip2018的勇士
  17. navicat如何导出mysql数据表结构
  18. CSOM中如何取到managed metadata类型字段的类型信息
  19. Android MVP模式简单易懂的介绍方式 (二)
  20. 安装Chrome driver/ IE driver

热门文章

  1. Angular中的内置指令和自定义指令
  2. linux环境下启动tomcat7出现时间过长(已经编译完成的项目)问题解决!
  3. jQuery事件函数位置放置的两种方法
  4. [2017-10-25]Abp系列——集成消息队列功能(基于Rebus.Rabbitmq)
  5. Struts2页面遍历
  6. go 文件上传
  7. (linux)BSP板级支持包开发理解
  8. UVA1378 A Funny Stone Game —— SG博弈
  9. 并不对劲的bzoj1095:p2056:[ZJOI2007]捉迷藏
  10. bzoj2957楼房重建——线段树