Python3.6 pip errors

I’ve installed python3-pip on Leap 15.4, but it errors whenever I try to use it:

pip list
/usr/lib/python3.6/site-packages/OpenSSL/crypto.py:14: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6.
  from cryptography import utils, x509
Traceback (most recent call last):
  File "/usr/bin/pip", line 11, in <module>
    load_entry_point('pip==20.0.2', 'console_scripts', 'pip3.6')()
  File "/usr/lib/python3.6/site-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/usr/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3.6/site-packages/pip/_internal/commands/list.py", line 13, in <module>
    from pip._internal.cli.req_command import IndexGroupCommand
  File "/usr/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 15, in <module>
    from pip._internal.index.package_finder import PackageFinder
  File "/usr/lib/python3.6/site-packages/pip/_internal/index/package_finder.py", line 21, in <module>
    from pip._internal.index.collector import parse_links
  File "/usr/lib/python3.6/site-packages/pip/_internal/index/collector.py", line 12, in <module>
    from pip._vendor import html5lib, requests
  File "/usr/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
    from pip._vendor.urllib3.contrib import pyopenssl
  File "/usr/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python3.6/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3.6/site-packages/OpenSSL/crypto.py", line 1556, in <module>
    class X509StoreFlags(object):
  File "/usr/lib/python3.6/site-packages/OpenSSL/crypto.py", line 1577, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'

Any ideas how to fix it?

@dimesio Hi is python36-pyOpenSSL installed?

I have python3-pyOpenSSL installed, version21.0.0-150400.3.3.1-noarch from Update repository.

@dimesio then it might need the pip3 version, you can’t find what python modules you need without resorting to pip?

pip3 install pyOpenSSL --upgrade

I have specialized python scripts for work, they have to be installed with pip.

Trying to upgrade pip just gives the same errors:

pip3 install pyOpenSSL --upgrade
/usr/lib/python3.6/site-packages/OpenSSL/crypto.py:14: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6.
  from cryptography import utils, x509
Traceback (most recent call last):
  File "/usr/bin/pip3", line 11, in <module>
    load_entry_point('pip==20.0.2', 'console_scripts', 'pip3.6')()
  File "/usr/lib/python3.6/site-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/usr/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 24, in <module>
    from pip._internal.cli.req_command import RequirementCommand
  File "/usr/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 15, in <module>
    from pip._internal.index.package_finder import PackageFinder
  File "/usr/lib/python3.6/site-packages/pip/_internal/index/package_finder.py", line 21, in <module>
    from pip._internal.index.collector import parse_links
  File "/usr/lib/python3.6/site-packages/pip/_internal/index/collector.py", line 12, in <module>
    from pip._vendor import html5lib, requests
  File "/usr/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
    from pip._vendor.urllib3.contrib import pyopenssl
  File "/usr/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python3.6/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3.6/site-packages/OpenSSL/crypto.py", line 3279, in <module>
    _lib.OpenSSL_add_all_algorithms()
AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'

So Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6. from cryptography import utils, x509, need to upgrade python…

@dimesio you can use py2pack and create a local rpm?

Tar your python script up with a version;

py2pack generate <yourpypackage-n.n.n.tar.gz>  -f python-yourpypackage.spec

Copy to spec to ~/.rpmbuild/SPECS source to ~/.rpmbuild/SOURCES cd to ~/.rpmbuild/SPECS and rpmbuild -ba python-yourpypackage.spec.

Interesting idea, but py2pack errors:

 py2pack generate import2ledger-1.4.5.tar.gz  -f python-import2ledger.spec
Traceback (most recent call last):
  File "/usr/bin/py2pack", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/py2pack/__init__.py", line 365, in main
    args.func(args)
  File "/usr/lib/python3.6/site-packages/py2pack/__init__.py", line 232, in generate
    fetch_data(args)
  File "/usr/lib/python3.6/site-packages/py2pack/__init__.py", line 274, in fetch_data
    releases = args.fetched_data['releases']
KeyError: 'releases'

I may try installing python 3.8 just for my work scripts. The base packages are in https://download.opensuse.org/repositories/devel:/languages:/python:/Factory/15.4

You installed it from where, you installed it how …

I cannot reproduce it. pip command in Leap 15.4 is provided by package python3-pip-20.0.2-150400.15.6.noarch and I get no errors, it lists installed Python (3) modules.

You either have repository mix or you installed some of Python components bypassing openSUSE packages.

I installed it with Yast from the Update repository:

That’s the package I have installed.

Most of the packages are from the Update repository, but some are from SUSE:SLE-15:Update. These are the python3 packages I have installed (many were pulled in by other packages):

zypper search -i python3
Loading repository data...
Reading installed packages...

S  | Name                       | Summary                                         | Type
---+----------------------------+-------------------------------------------------+--------
i  | libpython3_6m1_0           | Python Interpreter shared library               | package
i  | libsamba-policy0-python3   | Active Directory Group Policy library           | package
i  | python3                    | Python 3 Interpreter                            | package
i  | python3-apipkg             | Namespace control and lazy-import mechanism     | package
i  | python3-apparmor           | Python 3 interface for libapparmor functions    | package
i  | python3-appdirs            | A small Python module for determining platfor-> | package
i  | python3-asn1crypto         | ASN.1 parser and serializer for Python          | package
i  | python3-attrs              | Attributes without boilerplate                  | package
i  | python3-Babel              | Internationalization utilities                  | package
i  | python3-base               | Python 3 Interpreter and Stdlib Core            | package
i  | python3-bind               | A module allowing rndc commands to be sent fr-> | package
i  | python3-brotlipy           | Python binding to the Brotli library            | package
i  | python3-cairocffi          | Python cairo bindings based on cffi             | package
i  | python3-cepces             | Python part of cepces                           | package
i  | python3-certifi            | Python package for providing Mozilla's CA Bun-> | package
i  | python3-cffi               | Foreign Function Interface for Python calling-> | package
i  | python3-chardet            | Universal encoding detector                     | package
i  | python3-cmdln              | An improved cmd.py for Writing Multi-command -> | package
i  | python3-configobj          | Config file reading, writing and validation     | package
i  | python3-createrepo_c       | Python 3 bindings for the createrepo_c library  | package
i  | python3-cryptography       | Python library which exposes cryptographic re-> | package
i  | python3-cssselect          | CSS3 selectors for Python                       | package
i+ | python3-cupshelpers        | High-level Python Bindings for CUPS             | package
i  | python3-curses             | Python Interface to the (N)Curses Library       | package
i  | python3-Cycler             | Composable style cycles                         | package
i  | python3-dbm                | Python Interface to the GDBM Library            | package
i  | python3-dbus-python        | Python bindings for D-Bus                       | package
i  | python3-decorator          | Decorators for Humans                           | package
i+ | python3-devel              | Include Files and Libraries Mandatory for Bui-> | package
i+ | python3-dulwich            | Pure-Python Git Library                         | package
i  | python3-entrypoints        | Discover and load entry points from installed-> | package
i  | python3-fastimport         | Fastimport parser in Python                     | package
i  | python3-feedparser         | Universal Feed Parser Module for Python         | package
i  | python3-firewall           | Python3 bindings for FirewallD                  | package
i  | python3-gevent             | Python network library that uses greenlet and-> | package
i  | python3-geventhttpclient   | HTTP client library for gevent                  | package
i  | python3-gobject            | Python bindings for GObject                     | package
i  | python3-gobject-cairo      | Python bindings for GObject/Cairo               | package
i  | python3-gobject-Gdk        | Python bindings for GObject/Gdk                 | package
i  | python3-gpg                | Python 3 bindings for GPGME, a library for ac-> | package
i  | python3-greenlet           | Lightweight in-process concurrent programming   | package
i  | python3-idna               | Internationalized Domain Names in Application-> | package
i  | python3-importlib-metadata | Tool to read metadata from Python packages      | package
i  | python3-iniconfig          | iniconfig: brain-dead simple config-ini parsing | package
i  | python3-jeepney            | Low-level, pure Python DBus protocol wrapper    | package
i  | python3-Jinja2             | A fast and easy to use template engine writte-> | package
i  | python3-keyring            | System keyring service access from Python       | package
i  | python3-keyrings.alt       | Alternate keyring implementations               | package
i  | python3-kiwisolver         | An implementation of the Cassowary constraint-> | package
i  | python3-ldb                | Python3 bindings for the LDB library            | package
i  | python3-linux-procfs       | Linux /proc abstraction classes                 | package
i  | python3-lxml               | Pythonic XML processing library                 | package
i  | python3-M2Crypto           | Crypto and SSL toolkit for Python               | package
i  | python3-MarkupSafe         | Implements a XML/HTML/XHTML Markup safe strin-> | package
i  | python3-matplotlib         | Plotting Library for Python                     | package
i  | python3-matplotlib-cairo   | Cairo backend for python3-matplotlib            | package
i  | python3-matplotlib-gtk3    | GTK3 backends for python3-matplotlib            | package
i  | python3-matplotlib-tk      | Tk backend for python3-matplotlib               | package
i  | python3-metaextract        | Module to collect metadata for Python modules   | package
i  | python3-more-itertools     | More routines for operating on iterables, bey-> | package
i  | python3-mysqlclient        | Python interface to MySQL                       | package
i  | python3-nftables           | Python interface for nftables                   | package
i  | python3-notify2            | Python interface to DBus notifications          | package
i  | python3-numpy              | NumPy array processing for numbers, strings, -> | package
i  | python3-olefile            | Python package to read and write Microsoft OL-> | package
i  | python3-ordered-set        | Custom MutableSet that remembers its order      | package
i  | python3-packaging          | Core utilities for Python packages              | package
i  | python3-patiencediff       | Python implementation of the patiencediff alg-> | package
i  | python3-pbr                | Python Build Reasonableness                     | package
i  | python3-Pillow             | Python Imaging Library (Fork)                   | package
i+ | python3-pip                | A Python package management system              | package
i+ | python3-pip-wheel          | A Python package management system              | package
i  | python3-playsound          | Single function module for playing sounds       | package
i  | python3-pluggy             | Plugin registration and hook calling mechanis-> | package
i  | python3-ply                | Python Lex & Yacc                               | package
i  | python3-progressbar        | Text Progressbar Library for Python             | package
i  | python3-psutil             | A process utilities module for Python           | package
i  | python3-py                 | Library with cross-python path, ini-parsing, -> | package
i+ | python3-py2pack            | Script for generating distribution packages f-> | package
i  | python3-pyasn1             | ASN.1 types and codecs                          | package
i  | python3-pycairo            | Python Bindings for Cairo                       | package
i  | python3-pycparser          | C parser in Python                              | package
i  | python3-pycups             | Python Bindings for CUPS                        | package
i  | python3-pycurl             | PycURL -- cURL library module                   | package
i  | python3-pykerberos         | High-level interface to Kerberos                | package
i+ | python3-pyOpenSSL          | Python wrapper module around the OpenSSL libr-> | package
i  | python3-pyparsing          | Grammar Parser Library for Python               | package
i  | python3-PySocks            | A Python SOCKS client module                    | package
i  | python3-pytest             | Python testing tool with autodiscovery and de-> | package
i  | python3-python-dateutil    | A Python Datetime Library                       | package
i  | python3-pytz               | World timezone definitions, modern and histor-> | package
i  | python3-pyudev             | Udev bindings for Python                        | package
i  | python3-pyxdg              | Implementations of freedesktop.org standards -> | package
i  | python3-PyYAML             | YAML parser and emitter for Python              | package
i  | python3-qt5                | Python bindings for Qt 5                        | package
i  | python3-qt5-sip            | The sip module support for PyQt5                | package
i  | python3-reportlab          | The Reportlab Toolkit                           | package
i  | python3-requests           | Python HTTP Library                             | package
i  | python3-requests-kerberos  | A Kerberos authentication handler for python--> | package
i  | python3-rpm                | Python Bindings for Manipulating RPM Packages   | package
i+ | python3-rustcfg            | Rust cfg expression parser in Python            | package
i  | python3-scour              | An SVG scrubber                                 | package
i  | python3-SecretStorage      | Python bindings to FreeDesktoporg Secret Serv-> | package
i  | python3-setuptools         | Enhancements to distutils for building and di-> | package
i+ | python3-setuptools-wheel   | Enhancements to distutils for building and di-> | package
i  | python3-sgmllib3k          | Python 3 port of sgmllib                        | package
i  | python3-six                | Python 2 and 3 compatibility utilities          | package
i  | python3-slip               | Miscellaneous convenience, extension and work-> | package
i  | python3-slip-dbus          | Convenience functions for dbus services         | package
i  | python3-solv               | Python3 bindings for the libsolv library        | package
i  | python3-talloc             | Python3 bindings for the Talloc library         | package
i  | python3-tdb                | Python3 bindings for the Tdb library            | package
i  | python3-tevent             | Python3 bindings for the Tevent library         | package
i  | python3-tk                 | TkInter, a Python Tk Interface                  | package
i  | python3-urllib3            | HTTP library with thread-safe connection pool-> | package
i+ | python3-virtualenv         | Virtual Python Environment builder              | package
i  | python3-wcwidth            | Number of Terminal column cells of wide-chara-> | package
i+ | python3-wheel              | A built-package format for Python               | package
i  | python3-xcffib             | A drop in replacement for xpyb, an XCB python-> | package
i  | python3-zipp               | Pathlib-compatible object wrapper for zip files | package
i  | samba-libs-python3         | Python3 dependencies of samba-libs              | package
i  | samba-python3              | Samba Python3 libraries                         | package
i  | yast2-python3-bindings     | Python3 bindings for the YaST platform          | package

If I uninstall the system pyOpenSSL pip works, but I need that package for the scripts I need for work.

Thank you for pointing me in the right direction! I had installed several packages from scripts downloaded from the developer’s sites. It turns out one of them installed a newer version of cryptography in ~/.local/lib/python3.6/site-packages/cryptography. I renamed that directory as a test, and the problem disappeared. It remains to be seen whether anything will stop working because of it.

Hello, this is Gulshan Negi.
Well, I did a search about it on Google, and I found that to resolve this issue, you need to update the version of Python as well as update packages. I hope it will help you.
Thanks