{"id":4779,"date":"2020-06-05T15:45:59","date_gmt":"2020-06-05T20:45:59","guid":{"rendered":"http:\/\/icesquare.com\/wordpress\/?p=4779"},"modified":"2020-06-05T15:51:49","modified_gmt":"2020-06-05T20:51:49","slug":"pythonimporterror-cannot-import-name-ssl_match_hostname","status":"publish","type":"post","link":"https:\/\/icesquare.com\/wordpress\/pythonimporterror-cannot-import-name-ssl_match_hostname\/","title":{"rendered":"[Python\/CentOS 7] ImportError: cannot import name ssl_match_hostname"},"content":{"rendered":"<p>I was testing the certbot on my Google Cloud \/ Google Compute Engine (CentOS 7) today, and I ran into the following issues:<\/p>\n<pre style='height:300px'>\r\nsudo certbot certonly --apache\r\nTraceback (most recent call last):\r\n  File \"\/bin\/certbot\", line 9, in module\r\n    load_entry_point('certbot==1.4.0', 'console_scripts', 'certbot')()\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/pkg_resources.py\", line 378, in load_entry_point\r\n    return get_distribution(dist).load_entry_point(group, name)\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/pkg_resources.py\", line 2566, in load_entry_point\r\n    return ep.load()\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/pkg_resources.py\", line 2260, in load\r\n    entry = __import__(self.module_name, globals(),globals(), ['__name__'])\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/certbot\/main.py\", line 2, in <module>\r\n    from certbot._internal import main as internal_main\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/certbot\/_internal\/main.py\", line 16, in <\/module><module>\r\n    from certbot import crypto_util\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/certbot\/crypto_util.py\", line 30, in <\/module><module>\r\n    from certbot import util\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/certbot\/util.py\", line 23, in <\/module><module>\r\n    from certbot._internal import constants\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/certbot\/_internal\/constants.py\", line 6, in <\/module><module>\r\n    from acme import challenges\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/acme\/challenges.py\", line 11, in <\/module><module>\r\n    import requests\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/requests\/__init__.py\", line 58, in <\/module><module>\r\n    from . import utils\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/requests\/utils.py\", line 32, in <\/module><module>\r\n    from .exceptions import InvalidURL\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/requests\/exceptions.py\", line 10, in <\/module><module>\r\n    from urllib3.exceptions import HTTPError as BaseHTTPError\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/urllib3\/__init__.py\", line 8, in <\/module><module>\r\n    from .connectionpool import (\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/urllib3\/connectionpool.py\", line 11, in <\/module><module>\r\n    from .exceptions import (\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/urllib3\/exceptions.py\", line 2, in <\/module><module>\r\n    from .packages.six.moves.http_client import (\r\n  File \"\/usr\/lib\/python2.7\/site-packages\/urllib3\/packages\/__init__.py\", line 3, in <\/module><module>\r\n    from . import ssl_match_hostname\r\nImportError: cannot import name ssl_match_hostname\r\n<\/module><\/pre>\n<p>In my case, it was caused by the stupid Google Cloud bloatware: Google Cloud SDK. When I set up the Google Cloud few years ago, Google loaded a lot of bloatware including Google Cloud SDK, which lives here: \/usr\/local\/share\/google\/google-cloud-sdk\/. If you take a look to this directory, you will notice that there are some python packages that may conflict with your system one. In my case, I have three conflicting packages, one from the EPEL repository, one from the PIP and one from Google Cloud SDK. They don&#8217;t get along with each other.<\/p>\n<p>Here is what I did:<\/p>\n<pre>\r\n\r\nfind \/usr\/ -name \"ssl_match_hostname\"\r\n\r\n#My Local server - Good and trouble free:\r\n\/usr\/lib\/python2.7\/site-packages\/backports\/ssl_match_hostname\r\n\/usr\/lib\/python2.7\/site-packages\/urllib3\/packages\/ssl_match_hostname\r\n\r\n\r\n#Google Cloud Server - Bad and gave me trouble:\r\n\/usr\/lib\/python2.7\/site-packages\/backports\/ssl_match_hostname\/\r\n\/usr\/lib\/python2.7\/site-packages\/pip\/_vendor\/urllib3\/packages\/ssl_match_hostname\/\r\n\/usr\/local\/share\/google\/google-cloud-sdk\/lib\/third_party\/urllib3\/packages\/ssl_match_hostname\/\r\n\r\n<\/pre>\n<p>So I ended up removing this package and reinstalling everything again:<\/p>\n<pre>\r\nsudo yum remove python2-urllib3\r\n\r\n\r\n#Notice that google-compute-engine and python-google-compute-engine are included here. They are the source of the problem:\r\n\r\n=============================================================================================================================================================================================================================================\r\n Package                                                           Arch                                        Version                                                      Repository                                                  Size\r\n=============================================================================================================================================================================================================================================\r\nRemoving:\r\n python2-urllib3                                                   noarch                                      1.24.1-2.el7                                                 @forensics                                                 708 k\r\nRemoving for dependencies:\r\n certbot                                                           noarch                                      1.4.0-1.el7                                                  @epel                                                       97 k\r\n google-compute-engine                                             noarch                                      1:20190916.00-g2.el7                                         @google-cloud-compute                                       18 k\r\n python-google-compute-engine                                      noarch                                      1:20191210.00-g1.el7                                         @google-cloud-compute                                      398 k\r\n python-requests                                                   noarch                                      2.6.0-9.el7_8                                                @updates                                                   341 k\r\n python-requests-toolbelt                                          noarch                                      0.8.0-3.el7                                                  @epel                                                      277 k\r\n python2-acme                                                      noarch                                      1.4.0-2.el7                                                  @epel                                                      347 k\r\n python2-boto                                                      noarch                                      2.45.0-3.el7                                                 @epel                                                      9.4 M\r\n python2-certbot                                                   noarch                                      1.4.0-1.el7                                                  @epel                                                      1.5 M\r\n python2-certbot-apache                                            noarch                                      1.4.0-1.el7                                                  @epel                                                      579 k\r\n\r\nTransaction Summary\r\n=============================================================================================================================================================================================================================================\r\nRemove  1 Package (+9 Dependent packages)\r\n\r\n\r\n\r\n<\/pre>\n<p>In my case, I reinstalled the packages I need:<\/p>\n<pre>\r\n#Reinstalling the certbot:\r\nsudo yum install certbot python2-certbot-apache\r\n<\/pre>\n<\/p>\n<p>Good luck!<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was testing the certbot on my Google Cloud \/ Google Compute Engine (CentOS 7) today, and I ran into the following issues: sudo certbot certonly &#8211;apache Traceback (most recent <a class=\"more-link\" href=\"https:\/\/icesquare.com\/wordpress\/pythonimporterror-cannot-import-name-ssl_match_hostname\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[6],"tags":[],"class_list":["post-4779","post","type-post","status-publish","format-standard","hentry","category-technology"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p1sqzr-1f5","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":3596,"url":"https:\/\/icesquare.com\/wordpress\/shared-object-libsqlite3-so-8-not-found\/","url_meta":{"origin":4779,"position":0},"title":"Shared object &#8220;libsqlite3.so.8&#8221; not found","author":"Derrick","date":"July 1, 2014","format":false,"excerpt":"I noticed some weird thing on my server today. When I ran some PHP code, I got the following error: PHP Warning: PHP Startup: Unable to load dynamic library '\/usr\/local\/lib\/php\/20121212-zts\/pdo_sqlite.so' - Shared object \"libsqliteo_sqlite.so\" in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '\/usr\/local\/lib\/php\/20121212-zts\/pdo_sqlite.so' - Shared\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1489,"url":"https:\/\/icesquare.com\/wordpress\/php-warning-php-startup-unable-to-load-dynamic-library-usrlocallibphp20090626tokyo_tyrant-so-usrlocallibphp20090626tokyo_tyrant-so-undefined-symbol-ps_globals-in-unknown-on-l\/","url_meta":{"origin":4779,"position":1},"title":"PHP Warning:  PHP Startup: Unable to load dynamic library &#8216;\/usr\/local\/lib\/php\/20090626\/tokyo_tyrant.so&#8217; &#8211; \/usr\/local\/lib\/php\/20090626\/tokyo_tyrant.so: Undefined symbol &#8220;ps_globals&#8221; in Unknown on line 0","author":"Derrick","date":"August 23, 2011","format":false,"excerpt":"Every time I upgrade the PHP and related extensions, I always run into the same problem with some PHP-PECL modules. Recently with the new release of PHP 5.3.7, there is no exception for the trouble. So what kind of trouble I have today? The Tokyo Tyrant (The middleman between my\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"\/wordpress\/wp-content\/uploads\/2011\/08\/tokyocabinet.png","width":350,"height":200},"classes":[]},{"id":3539,"url":"https:\/\/icesquare.com\/wordpress\/freebsdshared-object-libaprutil-1-so-5-not-found-required-by-httpd\/","url_meta":{"origin":4779,"position":2},"title":"[FreeBSD]Shared object &#8220;libaprutil-1.so.5&#8221; not found, required by &#8220;httpd&#8221;","author":"Derrick","date":"June 11, 2014","format":false,"excerpt":"I upgraded the Apache to 2.2.27 on my FreeBSD box via portmaster. The upgrade went very smooth. After the upgrade, I decide to test the Apache by restarting the server. Oh well, I got the following error message: [FreeBSD]Shared object \"libaprutil-1.so.5\" not found, required by \"httpd\" Oh well, looks like\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2502,"url":"https:\/\/icesquare.com\/wordpress\/freebsdproblem-to-update-php-port\/","url_meta":{"origin":4779,"position":3},"title":"[FreeBSD]Problem to update PHP port","author":"Derrick","date":"January 12, 2012","format":false,"excerpt":"A new version of PHP (5.3.9) was available in FreeBSD today. Since it contained a lot of security fixes and enhancements, I decided to give it a try. After testing the new PHP in couple test servers, I think it is ready to upgrade the PHP on the production server.\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2181,"url":"https:\/\/icesquare.com\/wordpress\/freebsd-updateinstalling-updates-install-usrsrcliblibcgenlibc_dlopen-c-no-such-file-or-directory\/","url_meta":{"origin":4779,"position":4},"title":"[FreeBSD-update]Installing updates&#8230;install: \/\/\/usr\/src\/lib\/libc\/gen\/libc_dlopen.c: No such file or directory","author":"Derrick","date":"December 23, 2011","format":false,"excerpt":"When I tried to upgrade my FreeBSD system today, I received a last minute Christmas gift from the FreeBSD team. :-) #sudo freebsd-update fetch Looking up update.FreeBSD.org mirrors... 4 mirrors found. Fetching metadata signature for 8.2-RELEASE from update4.FreeBSD.org... done. Fetching metadata index... done. Inspecting system... done. Preparing to download files...\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":603,"url":"https:\/\/icesquare.com\/wordpress\/weird-php-error-after-freebsd-port-upgrade\/","url_meta":{"origin":4779,"position":5},"title":"Weird PHP Error after FreeBSD port upgrade (PHP Warning:  PHP Startup: Unable to load dynamic library)","author":"Derrick","date":"April 6, 2010","format":false,"excerpt":"Today I upgraded the port on my FreeBSD box using portmaster tools: portmaster -Dai After that, I found that the PHP gave the following weird error: php -v PHP Warning: PHP Startup: Unable to load dynamic library '\/usr\/local\/lib\/php\/20060613\/memcached.so' - \/usr\/local\/lib\/php\/20060613\/memcached.so: Undefined symbol \" php_session_create_id\" in Unknown on line 0 PHP\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/4779","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/comments?post=4779"}],"version-history":[{"count":10,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/4779\/revisions"}],"predecessor-version":[{"id":4789,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/4779\/revisions\/4789"}],"wp:attachment":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media?parent=4779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/categories?post=4779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/tags?post=4779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}