【问题标题】:GPG: conflicting commands With Ubuntu Buster ContainerGPG:与 Ubuntu Buster 容器冲突的命令
【发布时间】:2019-11-04 14:27:08
【问题描述】:
root@324c911bba2f:/# curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: apt-key output should not be parsed (stdout is not a terminal)
100   983  100   983    0     0   5173      0 --:--:-- --:--:-- --:--:--  5146
gpg: conflicting commands

我尝试使用 VS Code 在我的 ubuntu 容器上安装 MS ODBC 驱动程序。 不幸的是,我无法在女士的installation 指导之后安装驱动程序。 图片详情如下:

    System:    Host: 324c911bba2f Kernel: 4.9.184-linuxkit x86_64 bits: 64 Console: tty 0 Distro: Debian GNU/Linux 10 (buster)
Machine:   Type: Desktop Mobo: Microsoft model: Virtual Machine v: Hyper-V UEFI Release v4.0
           serial: 1535-8066-3525-8144-3146-6191-62 BIOS: Microsoft v: Hyper-V UEFI Release v4.0 date: 08/31/2018
CPU:       Topology: Dual Core model: Intel Core i7-6820HQ bits: 64 type: MCP L2 cache: 8192 KiB
           Speed: 2718 MHz min/max: N/A Core speeds (MHz): 1: 2718 2: 2718
Graphics:  Message: No Device data found.
           Display: server: No display server data found. Headless machine? tty: 229x23
           Message: Advanced graphics data unavailable in console for root.
Audio:     Message: No Device data found.
Network:   Message: No Device data found.
           IF-ID-1: eth0 state: up speed: 10000 Mbps duplex: full mac: 02:42:ac:11:00:02
           IF-ID-2: ip6tnl0 state: down mac: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
           IF-ID-3: tunl0 state: down mac: 00:00:00:00
Drives:    Local Storage: total: 59.60 GiB used: 4.97 GiB (8.3%)
           ID-1: /dev/sda model: Virtual Disk size: 59.60 GiB
Partition: ID-1: / size: 58.42 GiB used: 2.48 GiB (4.2%) fs: overlay source: ERR-102
Sensors:   Message: No sensors data was found. Is sensors configured?
Info:      Processes: 3 Uptime: 4h 38m Memory: 2.67 GiB used: 581.0 MiB (21.3%) Init: N/A Shell: bash inxi: 3.0.32

如果我尝试先安装 pyodbc,我也会收到错误消息。

 Building wheel for pyodbc (setup.py): started
  Building wheel for pyodbc (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-k5va9x0c/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-k5va9x0c/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-y2_vqoa_ --python-tag cp38
       cwd: /tmp/pip-install-k5va9x0c/pyodbc/
  Complete output (14 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'pyodbc' extension
  creating build
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/src
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYODBC_VERSION=4.0.27 -I/usr/local/include/python3.8 -c src/buffer.cpp -o build/temp.linux-x86_64-3.8/src/buffer.o -Wno-write-strings
  In file included from src/buffer.cpp:12:
  src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
   #include <sql.h>
            ^~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------

所以可能我使用了完全错误的解决方法来安装 ODBC 驱动程序。 我的计划是将我的 python 容器与 hoste 客户端上的 Ms Sql 数据库连接起来。因此,我在我的代码中使用了 DSN 连接字符串。

  connection = Library.Scribts.OwnStdLib.GetConfigNetwork()

cnxn = pyodbc.connect('DSN=' + connection["DSN"]  + ';UID=' + connection["UID"] + ';PWD=' + connection["password"])
cursor = cnxn.cursor()

感谢任何想法或 cmets。 最佳 NOert

【问题讨论】:

    标签: sql-server python-3.x docker pyodbc


    【解决方案1】:

    所以我很高兴为我的问题找到解决方案。首先我得到了一个新方法。

    我的 Dockerfile: FROM python:3.8.0-buster 运行 apt-get 更新 运行 apt-get -y install freetds-dev freetds-bin unixodbc-dev tdsodbc

    COPY ./requirements.txt /requirements.txt
    COPY ./odbcinst.ini /etc/odbcinst.ini
    
    
    WORKDIR /
    
    RUN pip3 install -r requirements.txt
    
    COPY . / 
    

    我的 odbcinst.ini 在根目录

    [ODBC Driver 17 for SQL Server]
    Description=ODBC Driver 17 for SQL Server
    Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
    Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
    

    我使用连接的代码。

    https://gist.github.com/rduplain/1293636

    【讨论】:

      猜你喜欢
      • 2021-07-09
      • 2018-06-01
      • 2014-07-16
      • 1970-01-01
      • 2020-04-16
      • 1970-01-01
      • 2019-12-31
      • 2011-11-06
      • 1970-01-01
      相关资源
      最近更新 更多