zoukankan      html  css  js  c++  java
  • python 安装第三方模块

    安装第三方模块:
    
    在Python中,安装第三方模块,是通过setuptools这个工具完成的。
    
    Python有两个封装了setuptools的包管理工具:easy_install和pip。目前官方推荐使用pip。
    
    [root@node01 lib]# python
    Python 2.7.3 (default, Apr  1 2017, 09:53:01) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>  import Image
      File "<stdin>", line 1
        import Image
        ^
    IndentationError: unexpected indent
    
    
    安装pip:
    
    yum install *ssl* 
    
    安装编译python:
    
    [root@node01 ~]# python -V
    Python 2.7.3
    
    [root@node01 ~]# cd pip-1.5.4
    [root@node01 pip-1.5.4]# python setup.py install
    Traceback (most recent call last):
      File "setup.py", line 6, in <module>
        from setuptools import setup, find_packages
    ImportError: No module named setuptools
    
    
    解决的方案如下:
    下载:http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
    
    sh setuptools-0.6c11-py2.7.egg
    
    
    [root@node01 pip-1.5.4]# pip install PLL
    Traceback (most recent call last):
      File "/usr/local/bin/pip", line 8, in <module>
        load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
      File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 318, in load_entry_point
      File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2221, in load_entry_point
      File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1954, in load
      File "/usr/local/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/__init__.py", line 10, in <module>
        from pip.util import get_installed_distributions, get_prog
      File "/usr/local/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/util.py", line 18, in <module>
        from pip._vendor.distlib import version
      File "/usr/local/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/_vendor/distlib/version.py", line 14, in <module>
        from .compat import string_types
      File "/usr/local/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/_vendor/distlib/compat.py", line 31, in <module>
        from urllib2 import (Request, urlopen, URLError, HTTPError,
    ImportError: cannot import name HTTPSHandler
    
    
    原因在于openssl,openssl-devel两个文件包未正确安装。用下来的命令来安装:
    2
    yum install openssl -y
    yum install openssl-devel -y
    
    安装完成后,重新安装Python:
    cd python2.7
    ./configure
    make install
    
    [root@node01 Python-2.7.3]# pip install PLL
    Downloading/unpacking PLL
    
    
    
    [root@node01 ~]#  easy_install python-memcached
    Searching for python-memcached
    Reading http://pypi.python.org/simple/python-memcached/
    Best match: python-memcached 1.58
    Downloading https://pypi.python.org/packages/f7/62/14b2448cfb04427366f24104c9da97cf8ea380d7258a3233f066a951a8d8/python-memcached-1.58.tar.gz#md5=23b258105013d14d899828d334e6b044
    Processing python-memcached-1.58.tar.gz
    Running python-memcached-1.58/setup.py -q bdist_egg --dist-dir /tmp/easy_install-IlhCP0/python-memcached-1.58/egg-dist-tmp-FykfuA
    warning: no files found matching '*.rst'
    warning: no files found matching 'MakeFile'
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '.gitignore' found anywhere in distribution
    warning: no previously-included files matching '.DS_Store' found anywhere in distribution
    zip_safe flag not set; analyzing archive contents...
    Adding python-memcached 1.58 to easy-install.pth file
    
    Installed /usr/local/lib/python2.7/site-packages/python_memcached-1.58-py2.7.egg
    Processing dependencies for python-memcached
    Searching for six>=1.4.0
    Reading http://pypi.python.org/simple/six/
    Best match: six 1.10.0
    Downloading https://pypi.python.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55
    Processing six-1.10.0.tar.gz
    Running six-1.10.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-krGcdT/six-1.10.0/egg-dist-tmp-s5ooAX
    no previously-included directories found matching 'documentation/_build'
    zip_safe flag not set; analyzing archive contents...
    six: module references __path__
    Adding six 1.10.0 to easy-install.pth file
    
    Installed /usr/local/lib/python2.7/site-packages/six-1.10.0-py2.7.egg
    Finished processing dependencies for python-memcached
    
    
    查看模块说明:
    
    >>> help('memcache')

  • 相关阅读:
    JS计算两个日期时间之差之天数不正确
    nodejs 第一天
    SQLSERVER存储过程基本语法
    复制表结构和数据SQL语句
    SVN使用教程总结
    jquery hover事件只触发一次动画
    导出格式
    C# 反射给对象赋值遇到的问题——类型转换
    a标签下载
    检测到在集成的托管管道模式下不适用的 ASP.NET 设置。
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349612.html
Copyright © 2011-2022 走看看