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. 面试算法爱好者书籍/OJ推荐

    面试算法爱好者书籍/OJ推荐 这个书单也基本适用于准备面试. 一.教科书 基本上一般的算法课本介绍的范围都不会超出算法导论和算法引论的范围.读完这两本书,其它的算法课本大致翻翻也就知道是什么货色了. ...

  2. css定位的元素内层不自动扩高解决

        给最外层的CSS加上一行: 1 position: relative;             /* 给最外层加上这行 */

  3. Microsoft.AspNetCore.Identity 使用 mysql 报错处理

    1.使用mysql 首先要确定mysql connector 支的版本,正面是链接 https://dev.mysql.com/doc/connector-net/en/connector-net-e ...

  4. 如何缓存hbase数据以减少下次取数据的时间

    缓存从hbase取得的数据的好处是显而易见的,缓存到本地以后,如果下次的输入能够直接从已缓存的本地文件中取得数据就无需再次访问hbase数据库,这样一来数据量大的话可以节省大量的访问hbase数据库的 ...

  5. ZOJ - 3948 Marjar Cola 【循环】

    题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3948 题意 用 x 个 瓶身 可以 换 一瓶饮料 用 y 个 瓶 ...

  6. Lua学习笔记(1) ——语法

    1.  Lua -i main.lua -i 进入交互模式 -l 加载一个库 -e  “lua code” 直接在命令行执行lua code 2. 注释 -- This is a line comme ...

  7. Rime输入工具的修改与编译安装

    作为一个比较“事儿多”的五笔用户,在使用过几乎所有的主流输入工具后,我最终选择了定制性非常高(同时也比较难以上手)的Rime.刚开始是在Windows下使用小狼毫0.9.30版,这个工具在上屏速度.热 ...

  8. Android studio在ubuntu下安装【转】

    本文转载自:http://www.jianshu.com/p/776e3b52e930 这学期的Android课程要学Android比较底层的东西,所以老师要求在Linux下安装Android的开发环 ...

  9. 纯属娱乐,对入门Android有一定的帮助

    package android.m9;   import android.app.Activity; import android.os.Bundle; import android.view.Men ...

  10. codeforces C. New Year Ratings Change 解题报告

    题目链接:http://codeforces.com/problemset/problem/379/C 题目意思:有n个users,每个user都有自己想升的rating.要解决的问题是给予每个人不同 ...