Hướng dẫn please install python-dnf from distribution system - vui lòng cài đặt python-dnf từ hệ thống phân phối

Chúng tôi có một playbook vá OS Linux được viết và hoạt động trơn tru cho các máy chủ RHEL 7/8 nhưng gần đây đã xây dựng các máy chủ Rhel 8 đang đưa ra vấn đề về phiên bản mặc định của Python là 3.8.3 và nó hoạt động rất tốt với phiên bản Python 3.6.8. Nó rất lạ, nó không hoạt động trên phiên bản mới nhất của Python nhưng chúng tôi không tích cực trong việc hạ cấp phiên bản. Là một cách giải quyết, chúng tôi đã sử dụng Python thay thế để sử dụng 3.6.8 nhưng chúng tôi đang tìm kiếm giải pháp vĩnh viễn. Chúng tôi đang sử dụng phiên bản Ansible 2.10.6 và nút điều khiển là RHEL 8 với phiên bản kernel mới nhất được phát hành trong tháng này.

Chúng tôi đã cài đặt gói Python-DNF gói cũng như mô-đun PIP DNF được cài đặt trong cả nút bộ điều khiển và máy chủ từ xa nhưng điều đó không khắc phục được sự cố. Playbook hoạt động hoàn hảo với phiên bản Python 3.6.8.

Đầu ra mẫu

 # python
Python 3.8.0 (default, Mar  9 2020, 18:02:46) 
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dnf
Traceback (most recent call last):
  File "", line 1, in 

# python
Python 3.6.8 (default, Dec  5 2019, 15:45:45) 
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dnf
>>> 

Vài ngày trước tôi muốn chạy DNF nhưng tôi đã nhận được lỗi sau

Traceback (most recent call last):
  File "/usr/bin/dnf", line 57, in 
    from dnf.cli import main
ModuleNotFoundError: No module named 'dnf'

Vì vậy, tôi đã cố gắng chạy yum và tôi đã nhận được một cái gì đó tương tự:

Traceback (most recent call last):
  File "/usr/bin/yum", line 57, in 
    from dnf.cli import main
ModuleNotFoundError: No module named 'dnf'

Tôi không biết chuyện gì đã xảy ra và tôi hy vọng ai đó có thể giúp tôi tìm ra vấn đề và giải quyết nó. Điều duy nhất tôi biết là nó có thể liên quan đến thực tế là một vài ngày trước khi tôi cài đặt Tensorflow trong Python bằng cách sử dụng Conda. Mặc dù có vẻ như Conda không hoạt động bây giờ vì tôi nhận được điều này:

Traceback (most recent call last):
  File "/usr/bin/conda", line 6, in 
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3126, in 
    @_call_aside
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3110, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3139, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 581, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 898, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 784, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'conda==4.5.11' distribution was not found and is required by the application

Tôi đang sử dụng Fedora 29 Cảm ơn!

Đã đăng Thu ngày 14 tháng 10 năm 2021 12:52 PM

Hello,

Chúng tôi đang ở giữa việc thực hiện một buổi giới thiệu về việc di chuyển ứng dụng khách yum của chúng tôi sang DNF. Đây là trang chúng tôi đã đề cập đến việc di chuyển:
This is the page we've referred to concerning the migration :

https://community.ibm.com/community/user/power/communities/community-home/digestviewer/viewthread?GroupId=6211&MessageKey=8c7b2f79-929d-47f2-999e-91e41188fce3&CommunityKey=10c1d831-47ee-4d92-a138-b03f7896f7c9&tab=digestviewer#bm8c7b2f79-929d-47f2-999e-91e41188fce3

Nhưng sau khi chuyển đổi máy khách Trình quản lý gói, tất cả các playbook và vai trò ansible bằng cách sử dụng mô -đun YUM với mô -đun YUM4/DNF hoặc mô -đun DNF trả về lỗi sau:

Bao gồm: /opt/ansible/roles/shared-install_ips_pkg/tasks/install_dnf_ips_pkg.yml cho tệp mô-đun admin-tot02-lpusing /opt/freeware/lib/python3.7/site .Pypipelining được bật. Thiết lập kết nối SSH cho người dùng: Không SSH: EXEC SSH -C -O ControlMaster = auto -o ControlPersist = Có -o ServeraliveInterval = 60 -o ServeraliveCountMax = 3 -o stricthostKeyCheCking -Mic, gssapi-keyex, hostb trên '/bin/sh -c' "'"' sudo -h -s -n & nbsp; -u root /bin /sh -c '"'" '"'" '"'" '" /opt/phần mềm miễn phí/bin/python3 '"'" '' "'"' "'" không nhập mô-đun DNF Python bằng/opt/freeware/bin/python3 (3.7.11 (mặc định, sep & nbsp; 6 2021, 10:46:05) [GCC 8.3.0]). Đảm bảo bạn đã chỉ định chính xác ansible_python_interpreter. " không tải chương trình/opt/phần mềm miễn phí/bin/python3_32: \\ nrtld: 0712-001 ký hiệu _global__aixi_libsqlite3_so đã được tham chiếu của biểu tượng không được tìm thấy. đã tìm thấy. \\ n "," không thành công " le/modules/bao bì/os/dnf.py \\ ", dòng 523, trong _ensure_dnf \\ n & nbsp; Tệp \\ "/opt/freeware/lib/python3.7/trang web trang web/dnf/__ init __. Py \\", dòng 32, trong \\ n & nbsp; & nbsp; nhập dnf.base \\ n & nbsp; Tệp \\ "/opt/freeware/lib/python3.7/trang web trang web/dnf/base.py \\", dòng 29, trong \\ n & nbsp; & nbsp; nhập libdnf.transaction \\ n & nbsp; Tệp \\ "/opt/freeware/lib/python3.7/trang web trang web/libdnf/__ init __. Py \\", dòng 3, trong \\ n & nbsp; & nbsp; từ . nhập common_types \\ n & nbsp; Tệp \\ "/opt/freeware/lib/python3.7/trang web trang web/libdnf/common_types.py \\", dòng 13, trong \\ n & nbsp; & nbsp; từ . Nhập _common_types \\ n "," gọi ": {" module_args ": {" name ": [" openldap "]," state ":" Đã cài đặt "," update_cache ": true : Sai, "Bugfix": Sai, "vô hiệu hóa_gpg_check": Sai loại trừ ": []," installroot ":"/" "Lock_Timeout": 30, "Conf_file": null, "vô hiệu hóa_excludes": null, "download_dir": null, "list" Máy chủ thông qua SSH:
Using module file /opt/freeware/lib/python3.7/site-packages/ansible/modules/packaging/os/dnf.py
Pipelining is enabled.
ESTABLISH SSH CONNECTION FOR USER: None
SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=yes -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/acom/.ssh/cp-%h-%r-%u-%p admin-xt02-lp '/bin/sh -c '"'"'sudo -H -S -n  -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-cbqfkhqbbabiuosgmwwtltyrehbvgeoi ; /opt/freeware/bin/python3'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
(1, b'\n{"msg": "Could not import the dnf python module using /opt/freeware/bin/python3 (3.7.11 (default, Sep  6 2021, 10:46:05) [GCC 8.3.0]). Please install `python3-dnf` package or ensure you have specified the correct ansible_python_interpreter.", "results": [], "cmd": "dnf install -y python3-dnf", "rc": 255, "stdout": "", "stderr": "Could not load program /opt/freeware/bin/python3_32:\\nrtld: 0712-001 Symbol _GLOBAL__AIXI_libsqlite3_so was referenced\\n      from module python3_32(), but a runtime definition\\n\\t    of the symbol was not found.\\nrtld: 0712-001 Symbol _GLOBAL__AIXD_libsqlite3_so was referenced\\n      from module python3_32(), but a runtime definition\\n\\t    of the symbol was not found.\\n", "failed": true, "exception": "  File \\"/tmp/ansible_ansible.builtin.dnf_payload_f2f2v3p1/ansible_ansible.builtin.dnf_payload.zip/ansible/modules/packaging/os/dnf.py\\", line 523, in _ensure_dnf\\n  File \\"/opt/freeware/lib/python3.7/site-packages/dnf/__init__.py\\", line 32, in \\n    import dnf.base\\n  File \\"/opt/freeware/lib/python3.7/site-packages/dnf/base.py\\", line 29, in \\n    import libdnf.transaction\\n  File \\"/opt/freeware/lib/python3.7/site-packages/libdnf/__init__.py\\", line 3, in \\n    from . import common_types\\n  File \\"/opt/freeware/lib/python3.7/site-packages/libdnf/common_types.py\\", line 13, in \\n    from . import _common_types\\n", "invocation": {"module_args": {"name": ["openldap"], "state": "installed", "update_cache": true, "allow_downgrade": false, "autoremove": false, "bugfix": false, "disable_gpg_check": false, "disable_plugin": [], "disablerepo": [], "download_only": false, "enable_plugin": [], "enablerepo": [], "exclude": [], "installroot": "/", "install_repoquery": true, "install_weak_deps": true, "security": false, "skip_broken": false, "update_only": false, "validate_certs": true, "lock_timeout": 30, "conf_file": null, "disable_excludes": null, "download_dir": null, "list": null, "releasever": null}}}\n', b'')
Failed to connect to the host via ssh:

Nhiệm vụ [Chia sẻ-Install_IPS_PKG: Cài đặt DNF IPS PKG] ****** / TÌM HIỂU ****** / TÌM HIỂU ****** / TÌM HIỂU ****** / TÌM opt/ansible/vai trò/chia sẻ-install_ips_pkg/các tác vụ/install_dnf_ips_pkg.yml: 2 TraceBack đầy đủ là: & nbsp; Tệp "/tmp/ansible_ansible.builtin.dnf_payload_f2f2v3p1/ansible_ansible.builtin.dnf_payload.zip/ansible/modules/packaging/os/dnf.py" Tệp "/opt/freeware/lib/python3.7/site-packages/dnf/__init__.py", dòng 32, in & nbsp; & nbsp; Nhập DNF.Base & NBSP; Tệp "/opt/freeware/lib/python3.7/site-packages/dnf/base.py", dòng 29, in & nbsp; & nbsp; nhập libdnf.transaction & nbsp; Tệp "/opt/freeware/lib/python3.7/site-packages/libdnf/__init__.py", dòng 3, in & nbsp; & nbsp; từ . nhập common_types & nbsp; Tệp "/opt/freeware/lib/python3.7/site-packages/libdnf/common_types.py", dòng 13, in & nbsp; & nbsp; từ . Nhập _Common_TypesFatal: [Admin-TT02-LP]: Không thành công! => Đã thay đổi = FALSE & NBSP; CMD: DNF Install -y Python3 -DNF & NBSP; Nhu cầu: & nbsp; & nbsp; module_args: & nbsp; & nbsp; & nbsp; allow_doundgrade: false & nbsp; & nbsp; & nbsp; autoremove: false & nbsp; & nbsp; & nbsp; Bugfix: Sai & NBSP; & nbsp; & nbsp; Conf_file: null & nbsp; & nbsp; & nbsp; vô hiệu hóa_excludes: null & nbsp; & nbsp; & nbsp; vô hiệu hóa_gpg_check: false & nbsp; & nbsp; & nbsp; vô hiệu hóa_plugin: [] & nbsp; & nbsp; & nbsp; vô hiệu hóa: [] & nbsp; & nbsp; & nbsp; download_dir: null & nbsp; & nbsp; & nbsp; download_only: false & nbsp; & nbsp; & nbsp; enable_plugin: [] & nbsp; & nbsp; & nbsp; enableRepo: [] & nbsp; & nbsp; & nbsp; loại trừ: [] & nbsp; & nbsp; & nbsp; install_repoquery: Đúng & nbsp; & nbsp; & nbsp; install_weak_deps: true & nbsp; & nbsp; & nbsp; installRoot: /& nbsp; & nbsp; & nbsp; Danh sách: NULL & NBSP; & nbsp; & nbsp; Lock_Timeout: 30 & nbsp; & nbsp; & nbsp; Tên: & nbsp; & nbsp; & nbsp; - Openldap & nbsp; & nbsp; & nbsp; Phát hành: NULL & NBSP; & nbsp; & nbsp; Bảo mật: Sai & NBSP; & nbsp; & nbsp; SKIP_BROKEN: FALSE & NBSP; & nbsp; & nbsp; Trạng thái: Đã cài đặt & NBSP; & nbsp; & nbsp; update_cache: true & nbsp; & nbsp; & nbsp; update_only: false & nbsp; & nbsp; & nbsp; VALIDITY_CERTS: Đúng & NBSP; MSG: Không thể nhập mô -đun DNF Python bằng/opt/phần mềm miễn phí/bin/python3 (3.7.11 (mặc định, sep & nbsp; 6 2021, 10:46:05) [GCC 8.3.0]). Vui lòng cài đặt gói `python3-dnf` hoặc đảm bảo bạn đã chỉ định đúng ansible_python_interpreter. & Nbsp; RC: 255 & nbsp; Kết quả: [] & nbsp; stderr: |-& nbsp; & nbsp; Không thể tải chương trình/opt/phần mềm miễn phí/bin/python3_32: & nbsp; & nbsp; RTLD: 0712-001 Biểu tượng _global__AIXI_LIBSQLITE3_SO đã được tham chiếu & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; từ mô -đun python3_32 (), nhưng định nghĩa thời gian chạy & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; của biểu tượng không được tìm thấy. & nbsp; & nbsp; RTLD: 0712-001 Biểu tượng _global__AIXD_LIBSQLITE3_SO đã được tham chiếu & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; từ mô -đun python3_32 (), nhưng định nghĩa thời gian chạy & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; của biểu tượng không được tìm thấy. & nbsp; stderr_lines: & nbsp; stdout: '' & nbsp; stdout_lines:
task path: /opt/ansible/roles/shared-install_ips_pkg/tasks/install_dnf_ips_pkg.yml:2
The full traceback is:
  File "/tmp/ansible_ansible.builtin.dnf_payload_f2f2v3p1/ansible_ansible.builtin.dnf_payload.zip/ansible/modules/packaging/os/dnf.py", line 523, in _ensure_dnf
  File "/opt/freeware/lib/python3.7/site-packages/dnf/__init__.py", line 32, in
    import dnf.base
  File "/opt/freeware/lib/python3.7/site-packages/dnf/base.py", line 29, in
    import libdnf.transaction
  File "/opt/freeware/lib/python3.7/site-packages/libdnf/__init__.py", line 3, in
    from . import common_types
  File "/opt/freeware/lib/python3.7/site-packages/libdnf/common_types.py", line 13, in
    from . import _common_types
fatal: [admin-xt02-lp]: FAILED! => changed=false
  cmd: dnf install -y python3-dnf
  invocation:
    module_args:
      allow_downgrade: false
      autoremove: false
      bugfix: false
      conf_file: null
      disable_excludes: null
      disable_gpg_check: false
      disable_plugin: []
      disablerepo: []
      download_dir: null
      download_only: false
      enable_plugin: []
      enablerepo: []
      exclude: []
      install_repoquery: true
      install_weak_deps: true
      installroot: /
      list: null
      lock_timeout: 30
      name:
      - openldap
      releasever: null
      security: false
      skip_broken: false
      state: installed
      update_cache: true
      update_only: false
      validate_certs: true
  msg: Could not import the dnf python module using /opt/freeware/bin/python3 (3.7.11 (default, Sep  6 2021, 10:46:05) [GCC 8.3.0]). Please install `python3-dnf` package or ensure you have specified the correct ansible_python_interpreter.
  rc: 255
  results: []
  stderr: |-
    Could not load program /opt/freeware/bin/python3_32:
    rtld: 0712-001 Symbol _GLOBAL__AIXI_libsqlite3_so was referenced
          from module python3_32(), but a runtime definition
                of the symbol was not found.
    rtld: 0712-001 Symbol _GLOBAL__AIXD_libsqlite3_so was referenced
          from module python3_32(), but a runtime definition
                of the symbol was not found.

  stderr_lines:
  stdout: ''
  stdout_lines:

Chơi Recap ****** / TÌM HIỂU ****** / TÌM HIỂU ****** / TÌM HIỂU ****** / TÌM HIỂU ****** / TÌM HIỂU; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; : OK = 4 & nbsp; & nbsp; đã thay đổi = 1 & nbsp; & nbsp; không thể truy cập được = 0 & nbsp; & nbsp; thất bại = 1 & nbsp; & nbsp; Bỏ qua = 2 & nbsp; & nbsp; được giải cứu = 0 & nbsp; & nbsp; bị bỏ qua = 0
admin-xt02-lp              : ok=4    changed=1    unreachable=0    failed=1    skipped=2    rescued=0    ignored=0

Khi xem xét điều này, tôi đã tìm thấy nhiều luồng như thế này:

https://community.ibm.com/community/user/power/communities/community-home/digestviewer/viewthread?GroupId=6211&MID=143335&CommunityKey=10c1d831-47ee-4d92-a138-b03f7896f7c9&tab=digestviewer

Tôi đã thử cài đặt lại SQLite và BZIP2, nhưng máy chủ Lỗi RemainSthis đã được nâng cấp lên & NBSP; Ansible.output của LSLPP -LC RPM.RTE:
This server has been upgraded to 7200-05-03-2136, so not the same level as mentioned in the thread but the problem is the same.
The package manager works fine outside Ansible.
Output of lslpp -Lc rpm.rte :

#Package Tên: FileSet: Level: State: PTF ID: FIX State: Loại: Mô tả: Destination Dir.:unStaller: Message Danh mục: Bộ thông báo: Số tin nhắn: Phụ huynh: Tự động: EFIX bị khóa: Cài đặt đường dẫn: Build Daterpm.rte: RPM.RTE: 4.15.1.3 ::
rpm.rte:rpm.rte:4.15.1.3: : :C: :RPM Package Manager: : : : : : :0:0:/:

Davy Keppens

------------------------------ Davy Keppens ---------------------- ------------
Davy Keppens
------------------------------

Làm thế nào cài đặt DNF trong Linux?

Cài đặt DNF trong RHEL/CentOS 7..
Để cài đặt DNF trên các hệ thống RHEL/CentOS 7, bạn cần thiết lập và bật EPEL YUM REPO trước khi cài đặt DNF. # YUM Cài đặt EPEL-RELEASE ..
Cài đặt DNF. # Yum Cài đặt DNF ..
Bây giờ bạn có thể bắt đầu chạy các lệnh bằng DNF. Để xem trang người đàn ông, bạn có thể sử dụng lệnh sau:.

DNF trong Python là gì?

DNF hoặc Dandified Yum là phiên bản thế hệ tiếp theo của Updater YellowDog, Modified (YUM), Trình quản lý gói cho các bản phân phối Linux dựa trên .RPM.the next-generation version of the Yellowdog Updater, Modified (yum), a package manager for . rpm-based Linux distributions.

Làm thế nào cài đặt gói DNF trong fedora?

DNF có thể được sử dụng chính xác như yum để tìm kiếm, cài đặt hoặc xóa các gói ...
Để tìm kiếm các kho lưu trữ cho một loại gói: # DNF Tìm kiếm gói PackAgename ..
Để cài đặt gói: # DNF Cài đặt PackAgename ..
Để xóa gói: # DNF Xóa PackAgename ..

DNF có sử dụng Python không?

DNF sử dụng LIB LIBSOLV để giải quyết, phát triển và duy trì bằng SUSE để cải thiện hiệu suất.Nó được viết chủ yếu bằng Python, và nó có cách riêng để đối phó với độ phân giải phụ thuộc.API của nó không được ghi lại đầy đủ và hệ thống mở rộng của nó chỉ cho phép các plugin Python.