Python error on running any `blockstack` command

I receive this Python traceback after trying to run blockstack setup or any other `blockstack command.

Traceback (most recent call last):
  File "/usr/local/bin/blockstack", line 42, in <module>
    from blockstack_client.cli import run_cli, exit_with_error
  File "/usr/local/lib/python2.7/dist-packages/blockstack_client/__init__.py", line 23, in    <module>
    import app
  File "/usr/local/lib/python2.7/dist-packages/blockstack_client/app.py", line 27, in <module>
    import jsonschema
  File "/usr/local/lib/python2.7/dist-packages/jsonschema/__init__.py", line 18, in <module>
    from jsonschema.validators import (
  File "/usr/local/lib/python2.7/dist-packages/jsonschema/validators.py", line 8, in  <module>
    import requests
  File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 84, in <module>
    from urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

tried to pip install pyOpenSSL and recieved requirements already satisfied. Problem still persists

Ubuntu 16.04

Hey @Rimann,

Can you try running sudo pip install --upgrade requests? Errors like this can occur when the requests package is out of date.

@jude Ran the given command. All requirements up to date. Problem still persists exactly

EDIT
found solution

  1. Uninstalled pyOpenSSL with sudo’s -H flag
    sudo -H pip uninstall pyOpenSSL

  2. upgrade pip with -H flag
    sudo -H pip install --upgrade pip

  3. Reinstall pyOpenSSL:
    sudo -H pip uninstall pyOpenSSL

1 Like

I dont know if this will be helpful but when running your command with sudo’s -H flag I get a traceback to the exact same error

Sorry, I’m confused. Are you saying blockstack setup is still causing the same error, or sudo -H blockstack setup? Does blockstack setup work correctly, once your solution is applied?

No this command you gave me sudo pip install --upgrade requests with the -H flag traced back to the same error as my op. Something must have been wrong with my PyOpenSSL. The re-install solved all the errors. That message was posted before my edit with the solution.