GPG:与Ubuntu Buster容器冲突的命令

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驱动程序。 不幸的是,在Ms。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
  ----------------------------------------

因此,可能我使用完全错误的workaraound来安装ODBC驱动程序。 我的计划是将python容器与hoste Client上的Ms Sql数据库连接。因此,我在代码中使用了Dsn连接字符串。

  connection = library.Scribts.OwnStdLib.getconfigNetwork()

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

非常感谢您提出任何想法或意见。 最佳NOert

gechenlei 回答:GPG:与Ubuntu Buster容器冲突的命令

因此,我很高兴为我的issu解决方案。首先,我有了新的方法。

我的Dockerfile:     来自python:3.8.0-buster     运行apt更新     运行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

本文链接:https://www.f2er.com/3166000.html

大家都在问