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安装成功,可以安装自已想要的模块,解决模块的依赖关系。

python的pip管理工具的更多相关文章

  1. python安装pip管理工具

    (1)安装python2.7.5,这里我选择安装在C盘根目录下. (2)安装完毕后C盘会生成一个叫“python27”的文件夹. (3)打开python27,会发现该目录下存在一个叫Scripts的文 ...

  2. Python的包管理工具Pip (zz )

    Python的包管理工具Pip 接触了Ruby,发现它有个包管理工具RubyGem很好用,并且有很完备的文档系统http://rdoc.info 发现Python下也有同样的工具,包括easy_ins ...

  3. Windows 安装 pip管理工具

    Step 1: 设置Python环境变量(我的Python 是 2.7.3) SETX PATH "%path%;D:\python;D:\python\Scripts" 也可以在 ...

  4. Python的包管理工具

    Python的包管理工具 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.为什么使用包管理 Python的模块或者源文件直接可以复制到目标项目目录中,就可以导入使用了. 但是为了 ...

  5. 【转载】Python的包管理工具Pip

    接触了Ruby,发现它有个包管理工具RubyGem很好用,并且有很完备的文档系统http://rdoc.info 发现Python下也有同样的工具,包括easy_install和Pip.不过,我没有细 ...

  6. Python的包管理工具Pip

    接触了Ruby,发现它有个包管理工具RubyGem非常好用,而且有非常完备的文档系统http://rdoc.info 发现Python下也有相同的工具,包含easy_install和Pip.只是,我没 ...

  7. window环境下安装 pip 工具 【pip为Python的扩展管理工具】

    Python有一些扩展管理工具,例如easy_install和pip工具,我推荐各位使用pip工具,因为pip工具具有很好的安装和卸载体验. 我们首先需要打开pip的官方网站, 下载必要的文件包,然后 ...

  8. Python之包管理工具:distutils、setuptools、distribute、setup.py、easy_install、easy_install、pip

    在安装Python包的过程中,经常涉及到distutils.setuptools.distribute.setup.py.easy_install.easy_install和pip等等. 介绍:htt ...

  9. 5、Python之包管理工具pip

    pip提供我们各色各样的软件(第三方库),而这些第三方库又可以给我们实现各种各样不同的功能,科学计算.画图.操作文件.聊天-- 我们可以通过Cmd终端.Pycharm.Jupyter三种平台使用pip ...

随机推荐

  1. Windows server 2008 R2 如何启动任务计划程序

    使用windows server 2008 R2  的任务计划程序需要启动服务 Task Scheduler 服务, windows server 2008 R2 默认状态下Task Schedule ...

  2. Ubuntu 14.04中安装tftp

    1. 安装sudo apt-get install tftp-hpa tftpd-hpa 2. 建立目录sudo mkdir /tftpboot sudo chmod 0777 /tftpbootsu ...

  3. Gym - 100283K K. Cubes Shuffling —— 贪心

    题目链接:http://codeforces.com/gym/100283/problem/K 题解: 要使其相邻两项的差值之和最小,那么越靠中间,其数值越小. 那么剩下的问题就是如何放数字了.一开始 ...

  4. Dubbo与Zookeeper、SpringMVC整合与使用(干货-理论放一遍。。。还未完结!)

    Dubbo跟Zookeeper的简介分享两个不错的链接: Dubbo简介:http://shiyanjun.cn/archives/325.html Zookeeper简介:http://www.op ...

  5. 数据库之Oracle

    数据库之Oracle 一. 用户的管理 1. 用户就是好比公司的某个人,而权限是这个人能在公司做什么,他的角色就是说明他的职位. 2. 用户的权限分为: 系统权限:对别的用户的管理操作. 对象权限:对 ...

  6. (原创)让mongodb的secondary支持读操作

    对于replica set 中的secondary 节点默认是不可读的.在写多读少的应用中,使用Replica Sets来实现读写分离.通过在连接时指定或者在主库指定slaveOk,由Secondar ...

  7. opencv Mat.at

    opencv c++ mat获取像素及像素赋值 For accessing pixel's channel value : ; i < image.cols; i++) { ; j < i ...

  8. python读写mysql总结

    一.MySQLdb包的安装 1. 在win环境下,下载MySQL-python-1.2.3,有两种方式: (1) 下载src源码.tar.gz(这个源码需要build编译再安装.egg包(当于.jar ...

  9. 5-1条件运算符 & 5-2

    三目运算符 新建类: ConditionDemo 用三目运算符: package com.imooc.operator; public class ConditionDemo { public sta ...

  10. struts2注解的作用

    Struts2注解 1 Struts2注解的作用 使用注解可以用来替换struts.xml配置文件!!! 2 导包 必须导入struts2-convention-plugin-2.3.15.jar包, ...