zoukankan      html  css  js  c++  java
  • ImportError: libsybdb.so.5: cannot open shared object file: No such file or directory pymssql linux 问题解决 搭建驱动

    [root@hadoop1 nlp]# python sqlserver_t.py
    Traceback (most recent call last):
      File "sqlserver_t.py", line 1, in <module>
        import pymssql
    ImportError: libsybdb.so.5: cannot open shared object file: No such file or directory

    [root@hadoop1 nlp]# yum install  freetds
    已加载插件:fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
     * epel: mirrors.aliyun.com
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    正在解决依赖关系
    --> 正在检查事务
    ---> 软件包 freetds.x86_64.0.0.95.81-1.el7 将被 安装
    --> 正在处理依赖关系 libodbc.so.2()(64bit),它被软件包 freetds-0.95.81-1.el7.x86_64 需要
    --> 正在处理依赖关系 libodbcinst.so.2()(64bit),它被软件包 freetds-0.95.81-1.el7.x86_64 需要
    --> 正在检查事务
    ---> 软件包 unixODBC.x86_64.0.2.3.1-11.el7 将被 安装
    --> 解决依赖关系完成

    依赖关系解决

    =======================================================================================================================================================================================================
     Package                                         架构                                          版本                                                  源                                           大小
    =======================================================================================================================================================================================================
    正在安装:
     freetds                                         x86_64                                        0.95.81-1.el7                                         epel                                        635 k
    为依赖而安装:
     unixODBC                                        x86_64                                        2.3.1-11.el7                                          base                                        413 k

    事务概要
    =======================================================================================================================================================================================================
    安装  1 软件包 (+1 依赖软件包)

    总下载量:1.0 M
    安装大小:3.9 M
    Is this ok [y/d/N]: y
    Downloading packages:
    (1/2): unixODBC-2.3.1-11.el7.x86_64.rpm                                                                                                                                         | 413 kB  00:00:01    
    (2/2): freetds-0.95.81-1.el7.x86_64.rpm                                                                                                                                         | 635 kB  00:00:13    
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    总计                                                                                                                                                                    76 kB/s | 1.0 MB  00:00:13    
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      正在安装    : unixODBC-2.3.1-11.el7.x86_64                                                                                                                                                       1/2
      正在安装    : freetds-0.95.81-1.el7.x86_64                                                                                                                                                       2/2
    warning: /etc/freetds.conf created as /etc/freetds.conf.rpmnew
      验证中      : unixODBC-2.3.1-11.el7.x86_64                                                                                                                                                       1/2
      验证中      : freetds-0.95.81-1.el7.x86_64                                                                                                                                                       2/2

    已安装:
      freetds.x86_64 0:0.95.81-1.el7                                                                                                                                                                      

    作为依赖被安装:
      unixODBC.x86_64 0:2.3.1-11.el7                                                                                                                                                                      

    完毕!
    [root@hadoop1 nlp]# find / | grep pymyssql
    [root@hadoop1 nlp]# find / | grep pymssql
    /home/data/test_xiaole/mylocalproject_BASE_OLD_framework/trunk/plugins/nlp/pymssql_test.py
    /home/data/xl_tmp/C/Users/Administrator.PC-201707311140/.PyCharmCE2017.2/system/python_stubs/-1023133876/pymssql.py
    /home/hadoop/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /home/hadoop/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /home/hadoop/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /home/hadoop/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql.cpython-36m-x86_64-linux-gnu.so
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/DESCRIPTION.rst
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/metadata.json
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/top_level.txt
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/WHEEL
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/METADATA
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/RECORD
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/INSTALLER
    /home/hadoop/.pycharm_helpers/typeshed/third_party/2/pymssql.pyi
    /root/.cache/pip/wheels/c1/1e/75/bc600eb8a5c9ed77fb1edf15ae5a48b5b427b0390c9a7c9dff/pymssql-2.1.3-cp36-cp36m-linux_x86_64.whl
    /root/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /root/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /root/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /root/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /root/.pycharm_helpers/typeshed/third_party/2/pymssql.pyi
    [root@hadoop1 nlp]# rm -rf /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql
    [root@hadoop1 nlp]# rm -f /root/.cache/pip/wheels/c1/1e/75/bc600eb8a5c9ed77fb1edf15ae5a48b5b427b0390c9a7c9dff/pymssql-2.1.3-cp36-cp36m-linux_x86_64.whl
    [root@hadoop1 nlp]# rm -rf /root/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/*mssql*
    [root@hadoop1 nlp]# find / | grep pymssql
    /home/data/test_xiaole/mylocalproject_BASE_OLD_framework/trunk/plugins/nlp/pymssql_test.py
    /home/data/xl_tmp/C/Users/Administrator.PC-201707311140/.PyCharmCE2017.2/system/python_stubs/-1023133876/pymssql.py
    /home/hadoop/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /home/hadoop/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /home/hadoop/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /home/hadoop/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql.cpython-36m-x86_64-linux-gnu.so
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/DESCRIPTION.rst
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/metadata.json
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/top_level.txt
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/WHEEL
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/METADATA
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/RECORD
    /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql-2.1.3.dist-info/INSTALLER
    /home/hadoop/.pycharm_helpers/typeshed/third_party/2/pymssql.pyi
    /root/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /root/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /root/.pycharm_helpers/typeshed/third_party/2/pymssql.pyi
    [root@hadoop1 nlp]# rm -rf /home/hadoop/anaconda3/lib/python3.6/site-packages/pymssql*
    [root@hadoop1 nlp]# find / | grep pymssql
    /home/data/test_xiaole/mylocalproject_BASE_OLD_framework/trunk/plugins/nlp/pymssql_test.py
    /home/data/xl_tmp/C/Users/Administrator.PC-201707311140/.PyCharmCE2017.2/system/python_stubs/-1023133876/pymssql.py
    /home/hadoop/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /home/hadoop/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /home/hadoop/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /home/hadoop/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /home/hadoop/.pycharm_helpers/typeshed/third_party/2/pymssql.pyi
    /root/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /root/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /root/.pycharm_helpers/typeshed/third_party/2/pymssql.pyi
    [root@hadoop1 nlp]# find / | grep pymssql
    /home/data/test_xiaole/mylocalproject_BASE_OLD_framework/trunk/plugins/nlp/pymssql_test.py
    /home/data/xl_tmp/C/Users/Administrator.PC-201707311140/.PyCharmCE2017.2/system/python_stubs/-1023133876/pymssql.py
    /home/hadoop/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /home/hadoop/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /home/hadoop/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /home/hadoop/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /home/hadoop/.pycharm_helpers/typeshed/third_party/2/pymssql.pyi
    /root/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /root/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /root/.pycharm_helpers/typeshed/third_party/2/pymssql.pyi
    [root@hadoop1 nlp]# rm -f /root/.pycharm_helpers/typeshed/third_party/2/pymss
    [root@hadoop1 nlp]# rm -f /root/.pycharm_helpers/typeshed/third_party/2/pymssql*
    [root@hadoop1 nlp]# find / | grep pymssql
    /home/data/test_xiaole/mylocalproject_BASE_OLD_framework/trunk/plugins/nlp/pymssql_test.py
    /home/data/xl_tmp/C/Users/Administrator.PC-201707311140/.PyCharmCE2017.2/system/python_stubs/-1023133876/pymssql.py
    /home/hadoop/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /home/hadoop/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /home/hadoop/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /home/hadoop/anaconda3/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    /home/hadoop/.pycharm_helpers/typeshed/third_party/2/pymssql.pyi
    /root/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/__pycache__/pymssql.cpython-36.pyc
    /root/anaconda3/pkgs/sqlalchemy-1.1.13-py36hfb5efd7_0/lib/python3.6/site-packages/sqlalchemy/dialects/mssql/pymssql.py
    [root@hadoop1 nlp]# yum install freetds
    已加载插件:fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
     * epel: mirrors.aliyun.com
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    软件包 freetds-0.95.81-1.el7.x86_64 已安装并且是最新版本
    无须任何处理
    [root@hadoop1 nlp]# pip install pymssql
    Collecting pymssql
      Using cached pymssql-2.1.3.tar.gz
    Building wheels for collected packages: pymssql
      Running setup.py bdist_wheel for pymssql ... done
      Stored in directory: /root/.cache/pip/wheels/c1/1e/75/bc600eb8a5c9ed77fb1edf15ae5a48b5b427b0390c9a7c9dff
    Successfully built pymssql
    Installing collected packages: pymssql
    Successfully installed pymssql-2.1.3
    [root@hadoop1 nlp]# ll -as
    总用量 116860
        4 drwxr-xr-x 2 root root     4096 12月 14 11:27 .
        0 drwxr-xr-x 8 root root      117 12月  5 16:48 ..
        8 -rw-r--r-- 1 root root     5743 12月 11 16:23 db_tab_con.py
     2112 -rw-r--r-- 1 root root  2161830 12月  6 09:34 list_b.sql
    95660 -rw-r--r-- 1 root root 97951846 12月 13 20:02 list_b_uid_title_sina_ask.txt
        4 -rw-r--r-- 1 root root     2850 12月 11 16:22 mg_sql.txt
        4 -rw-r--r-- 1 root root     1838 12月 13 19:35 myltp.py
        4 -rw-r--r-- 1 root root      289 12月  6 10:20 n_gram.py
        4 -rw-r--r-- 1 root root     1688 12月 14 11:19 pymssql_test.py
        4 -rw-r--r-- 1 root root      645 12月  6 09:20 rule_list.txt
        4 -rw-r--r-- 1 root root      741 12月 14 11:27 sqlserver_t.py
        4 -rw-r--r-- 1 root root      280 12月  8 16:20 t.py
      120 -rw-r--r-- 1 root root   121498 12月  6 17:02 国家统计局行政区划代码.txt
    14272 -rw-r--r-- 1 root root 14611853 12月  5 18:16 哪家.txt
     4656 -rw-r--r-- 1 root root  4767195 12月  5 17:52 哪里.txt
    [root@hadoop1 nlp]# python sqlserver_t.py
    [root@hadoop1 nlp]# python sqlserver_t.py
    {'c': 7855053}
    {'c': 32120982}
    {'c': 1861}
    {'c': 15239162}
    {'c': 2}
    {'c': 1441829}
    [root@hadoop1 nlp]# python pymssql_test.py
    Traceback (most recent call last):
      File "pymssql.pyx", line 635, in pymssql.connect (pymssql.c:10734)
      File "_mssql.pyx", line 1902, in _mssql.connect (_mssql.c:21821)
      File "_mssql.pyx", line 637, in _mssql.MSSQLConnection.__init__ (_mssql.c:6581)
      File "_mssql.pyx", line 1630, in _mssql.maybe_raise_MSSQLDatabaseException (_mssql.c:17524)
    _mssql.MSSQLDatabaseException: (20009, b'DB-Lib error message 20009, severity 9: Unable to connect: Adaptive Server is unavailable or does not exist (rm-2ze490nv1gsv17720.sqlserver.rds.aliyuncs.com:3443) Net-Lib error during Connection timed out (110) ')

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "pymssql_test.py", line 38, in <module>
        tds_version='7.1', conn_properties=None) as conn:
      File "pymssql.pyx", line 641, in pymssql.connect (pymssql.c:10824)
    pymssql.OperationalError: (20009, b'DB-Lib error message 20009, severity 9: Unable to connect: Adaptive Server is unavailable or does not exist (rm-2ze490nv1gsv17720.sqlserver.rds.aliyuncs.com:3443) Net-Lib error during Connection timed out (110) ')
    [root@hadoop1 nlp]# python pymssql_test.py
    Traceback (most recent call last):
      File "pymssql.pyx", line 447, in pymssql.Cursor.execute (pymssql.c:7119)
      File "_mssql.pyx", line 1011, in _mssql.MSSQLConnection.execute_query (_mssql.c:11586)
      File "_mssql.pyx", line 1042, in _mssql.MSSQLConnection.execute_query (_mssql.c:11466)
      File "_mssql.pyx", line 1175, in _mssql.MSSQLConnection.format_and_run_query (_mssql.c:12746)
      File "_mssql.pyx", line 1586, in _mssql.check_cancel_and_raise (_mssql.c:16880)
      File "_mssql.pyx", line 1630, in _mssql.maybe_raise_MSSQLDatabaseException (_mssql.c:17524)
    _mssql.MSSQLDatabaseException: (208, b"Invalid object name 'test'.DB-Lib error message 20018, severity 16: General SQL Server error: Check messages from the SQL Server ")

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "pymssql_test.py", line 41, in <module>
        cursor.execute(q)
      File "pymssql.pyx", line 464, in pymssql.Cursor.execute (pymssql.c:7491)
    pymssql.ProgrammingError: (208, b"Invalid object name 'test'.DB-Lib error message 20018, severity 16: General SQL Server error: Check messages from the SQL Server ")
    [root@hadoop1 nlp]# python pymssql_test.py
    {'ask_id': 1, 'smqid': '6DB9EB61B93443C0B390484AAE86E423', 'siteid': 31, 'userid': 33995585, 'title': '南网通是什么时候成立的?', 'catid': 4389, 'ask_time': 1443077708, 'questionId': '0', '_catid': 4302}
    {'ask_id': 2, 'smqid': '217883BA0D63413A84BC3BC42AEA5654', 'siteid': 31, 'userid': 34021057, 'title': '考博英语复习从何入手?', 'catid': 4190, 'ask_time': 1443078685, 'questionId': '0', '_catid': 3331}
    {'ask_id': 3, 'smqid': 'C670683D18634C26B6FF3C9A95703B4F', 'siteid': 40, 'userid': 34019886, 'title': '深圳哪有好的不锈钢电解抛光加工厂家', 'catid': 103, 'ask_time': 1443079067, 'questionId': '0', '_catid': 1}
    {'ask_id': 4, 'smqid': 'CE1B74324108405F8B3377703BBB6859', 'siteid': 31, 'userid': 34000840, 'title': '北京偶时代怎么样?', 'catid': 3989, 'ask_time': 1443079264, 'questionId': '0', '_catid': 3331}
    {'ask_id': 5, 'smqid': 'A7C896B08B084CB79C85AA9A2927ABBD', 'siteid': 31, 'userid': 34027587, 'title': '铜像雕塑哪里有加工厂', 'catid': 4181, 'ask_time': 1443079286, 'questionId': '0', '_catid': 3330}
    {'ask_id': 6, 'smqid': 'E90DD0E22AFE4D09AECDB959836F4428', 'siteid': 31, 'userid': 34010451, 'title': '多功能小吃车多少钱一辆?', 'catid': 4430, 'ask_time': 1443079327, 'questionId': '0', '_catid': 4303}
    [root@hadoop1 nlp]#

    先有驱动环境

    再 pip Install

    先删除之前的 pymssql 


    import pymssql

    """
    def __init__(self, server="localhost", user="sa", password="",

                 charset='UTF-8', database='', appname=None, port='1433', tds_version='7.1', conn_properties=None)

    """

    s, u, p, d, po,tab = 'rm-..rds.aliyuncs.com', 'sina_k', '564', 'sina_ask', '3433','st_buuu'
    with pymssql.connect(server=s, user=u, password=p, charset='UTF-8', database=d, appname=None, port=po,
                         tds_version='7.1', conn_properties=None) as conn:
        with conn.cursor(as_dict=True) as cursor:
            q = '%s%s' % ('SELECT TOP 6 * FROM ', tab)
            cursor.execute(q)
            for row in cursor:
                print(row)


    d =9

  • 相关阅读:
    JS制作图表
    把图片存入数据库
    .NET各种小问题
    JS各种小问题
    JS操作cookie
    JS处理Json数据
    git与svn的区别
    关于java中的一些循环
    java基础面试(上)
    Spring事务
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6994059.html
Copyright © 2011-2022 走看看