Python AttributeError: 'module' object has no attribute 'SSL_ST_INIT'












50















A Python script of mine is failing with:



Traceback (most recent call last):
File "./inspect_sheet.py", line 21, in <module>
main()
File "./inspect_sheet.py", line 12, in main
workbook_name=workbook_name,
File "./google_sheets.py", line 56, in __init__
self.login()
File "./google_sheets.py", line 46, in login
self.client = gspread.authorize(credentials)
File "/usr/local/lib/python2.7/site-packages/gspread/client.py", line 335, in authorize
client.login()
File "/usr/local/lib/python2.7/site-packages/gspread/client.py", line 98, in login
self.auth.refresh(http)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 598, in refresh
self._refresh(http.request)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 769, in _refresh
self._do_refresh_request(http_request)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 795, in _do_refresh_request
body = self._generate_refresh_request_body()
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 1425, in _generate_refresh_request_body
assertion = self._generate_assertion()
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 1554, in _generate_assertion
private_key, self.private_key_password), payload)
File "/usr/local/lib/python2.7/site-packages/oauth2client/crypt.py", line 162, in from_string
from OpenSSL import crypto
File "/usr/local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 118, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'









share|improve this question























  • I run in this problem with debian-jessie, upgraded package python-openssl (16.0.0-1~bpo8+1) from jessie-backports doesn't work too, so I have to upgrade it using pip according to solutions bellow (used version was 18.0.0)

    – iuridiniz
    Jan 2 at 20:52


















50















A Python script of mine is failing with:



Traceback (most recent call last):
File "./inspect_sheet.py", line 21, in <module>
main()
File "./inspect_sheet.py", line 12, in main
workbook_name=workbook_name,
File "./google_sheets.py", line 56, in __init__
self.login()
File "./google_sheets.py", line 46, in login
self.client = gspread.authorize(credentials)
File "/usr/local/lib/python2.7/site-packages/gspread/client.py", line 335, in authorize
client.login()
File "/usr/local/lib/python2.7/site-packages/gspread/client.py", line 98, in login
self.auth.refresh(http)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 598, in refresh
self._refresh(http.request)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 769, in _refresh
self._do_refresh_request(http_request)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 795, in _do_refresh_request
body = self._generate_refresh_request_body()
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 1425, in _generate_refresh_request_body
assertion = self._generate_assertion()
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 1554, in _generate_assertion
private_key, self.private_key_password), payload)
File "/usr/local/lib/python2.7/site-packages/oauth2client/crypt.py", line 162, in from_string
from OpenSSL import crypto
File "/usr/local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 118, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'









share|improve this question























  • I run in this problem with debian-jessie, upgraded package python-openssl (16.0.0-1~bpo8+1) from jessie-backports doesn't work too, so I have to upgrade it using pip according to solutions bellow (used version was 18.0.0)

    – iuridiniz
    Jan 2 at 20:52
















50












50








50


11






A Python script of mine is failing with:



Traceback (most recent call last):
File "./inspect_sheet.py", line 21, in <module>
main()
File "./inspect_sheet.py", line 12, in main
workbook_name=workbook_name,
File "./google_sheets.py", line 56, in __init__
self.login()
File "./google_sheets.py", line 46, in login
self.client = gspread.authorize(credentials)
File "/usr/local/lib/python2.7/site-packages/gspread/client.py", line 335, in authorize
client.login()
File "/usr/local/lib/python2.7/site-packages/gspread/client.py", line 98, in login
self.auth.refresh(http)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 598, in refresh
self._refresh(http.request)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 769, in _refresh
self._do_refresh_request(http_request)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 795, in _do_refresh_request
body = self._generate_refresh_request_body()
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 1425, in _generate_refresh_request_body
assertion = self._generate_assertion()
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 1554, in _generate_assertion
private_key, self.private_key_password), payload)
File "/usr/local/lib/python2.7/site-packages/oauth2client/crypt.py", line 162, in from_string
from OpenSSL import crypto
File "/usr/local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 118, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'









share|improve this question














A Python script of mine is failing with:



Traceback (most recent call last):
File "./inspect_sheet.py", line 21, in <module>
main()
File "./inspect_sheet.py", line 12, in main
workbook_name=workbook_name,
File "./google_sheets.py", line 56, in __init__
self.login()
File "./google_sheets.py", line 46, in login
self.client = gspread.authorize(credentials)
File "/usr/local/lib/python2.7/site-packages/gspread/client.py", line 335, in authorize
client.login()
File "/usr/local/lib/python2.7/site-packages/gspread/client.py", line 98, in login
self.auth.refresh(http)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 598, in refresh
self._refresh(http.request)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 769, in _refresh
self._do_refresh_request(http_request)
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 795, in _do_refresh_request
body = self._generate_refresh_request_body()
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 1425, in _generate_refresh_request_body
assertion = self._generate_assertion()
File "/usr/local/lib/python2.7/site-packages/oauth2client/client.py", line 1554, in _generate_assertion
private_key, self.private_key_password), payload)
File "/usr/local/lib/python2.7/site-packages/oauth2client/crypt.py", line 162, in from_string
from OpenSSL import crypto
File "/usr/local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 118, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'






python openssl pyopenssl






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 6 '17 at 23:10









Ben WheelerBen Wheeler

2,98312440




2,98312440













  • I run in this problem with debian-jessie, upgraded package python-openssl (16.0.0-1~bpo8+1) from jessie-backports doesn't work too, so I have to upgrade it using pip according to solutions bellow (used version was 18.0.0)

    – iuridiniz
    Jan 2 at 20:52





















  • I run in this problem with debian-jessie, upgraded package python-openssl (16.0.0-1~bpo8+1) from jessie-backports doesn't work too, so I have to upgrade it using pip according to solutions bellow (used version was 18.0.0)

    – iuridiniz
    Jan 2 at 20:52



















I run in this problem with debian-jessie, upgraded package python-openssl (16.0.0-1~bpo8+1) from jessie-backports doesn't work too, so I have to upgrade it using pip according to solutions bellow (used version was 18.0.0)

– iuridiniz
Jan 2 at 20:52







I run in this problem with debian-jessie, upgraded package python-openssl (16.0.0-1~bpo8+1) from jessie-backports doesn't work too, so I have to upgrade it using pip according to solutions bellow (used version was 18.0.0)

– iuridiniz
Jan 2 at 20:52














17 Answers
17






active

oldest

votes


















85














Upgrading pyopenssl with pip was not working as none of the commands related to to pip was working for me. By upgrading pyopenssl with easy_install, above problem can be solved.



sudo python -m easy_install --upgrade pyOpenSSL


credit @delimiter (Answer)






share|improve this answer



















  • 1





    Thanks! I had to restart my terminal / log back into my server after this command, and pip worked fine after that.

    – Jarvis Johnson
    May 1 '18 at 19:58











  • This worked for me.

    – Mehmet Kurtipek
    Sep 15 '18 at 15:30











  • meet the new error -error: Setup script exited with error: command 'gcc' failed with exit status 1

    – brainLoop
    Oct 8 '18 at 13:13





















67














Turned out the problem was with my installation of pyOpenSSL, pyOpenSSL-0.15.1 .



I did:



pip uninstall pyopenssl


and then



pip install pyopenssl


...and my Python script worked again!






share|improve this answer



















  • 24





    i had trouble running pip itself, this solved it sudo easy_install pyOpenSSL

    – chinmay
    Jul 27 '17 at 9:21








  • 2





    Had just upgraded cryptography; your solution was sufficient in my case

    – denvar
    Oct 20 '17 at 12:00






  • 3





    In my case I had to uninstalled like this: sudo aptitude purge python-openssl because it was installed with aptitude. I think I could do the same with apt-get

    – ChesuCR
    May 3 '18 at 11:21






  • 2





    pip uninstall pyonpenssl is throwing same error

    – brainLoop
    Oct 8 '18 at 12:33






  • 1





    I got the error every time I ran pip. So did rm -rf cryptography and could run pip again.

    – John Strood
    Oct 31 '18 at 7:43



















12














Update your pyopenssl module:



$ sudo pip install -U pyopenssl





share|improve this answer





















  • 1





    Thanks, I figure that is more efficient than uninstalling and installing again.

    – Ben Wheeler
    Sep 7 '17 at 22:19






  • 1





    if you use a virtualenv you don't need sudo.

    – Chris
    Feb 5 '18 at 13:50



















8














I experienced the same issue recently and after few hours investigation, I found out that it was caused by New cryptography 2.0 upgrade. This upgrade will break many packages using pyopenssl (like Sentry, Google Analytics and etc). Just downgrade it to 1.9 will solve the problem.



Be cautious if you are using "pip install -U", it will automatically upgrade packages that are not listed in requirements.txt.






share|improve this answer
























  • Thanks, this worked. Upgrading pyopenssl wasn't sufficient for me.

    – r11
    Oct 16 '17 at 6:23



















6














I had a similar error:



    from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py", line 112, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: module 'lib' has no attribute 'SSL_ST_INIT'


and none of the other answers could fix it, because pip could not install anything. Instead, what I did was this from the terminal first:



sudo rm -r /usr/local/lib/python3.5/dist-packages/OpenSSL


Then reinstalled pyopenssl with pip:



sudo pip install pyopenssl


and everything was gravy.






share|improve this answer































    2














    In my case, the problem was that the package was installed in root directories, and I was executing the script which asked for pyopenssl with my Linux user forvas. And that user can't use the libraries installed in root.



    So first I had to remove the package with aptitude or apt-get.



    sudo aptitude purge python-openssl


    Therefore, I had to install the package again, but taking into account the user who is executing the script which is asking for the library. Take a look to where the library is installed depending on the Linux user and the argument --user of pip.



    Case 1



    forvas@server:$ pip install pyopenssl



    Could not install packages due to an EnvironmentError:



    [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/OpenSSL'



    Consider using the --user option or check the permissions.




    Case 2



    forvas@server:$ sudo pip install pyopenssl



    /usr/local/lib/python2.7/dist-packages/OpenSSL/*



    /usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*




    Case 3



    forvas@server:$ sudo pip install --user pyopenssl



    /home/forvas/.local/lib/python2.7/site-packages/OpenSSL/*



    /home/forvas/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*




    Case 4



    root@server:$ pip install pyopenssl



    /usr/local/lib/python2.7/dist-packages/OpenSSL/*



    /usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*




    Case 5



    root@server:$ pip install --user pyopenssl



    /root/.local/lib/python2.7/site-packages/OpenSSL/*



    /root/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*




    Conclusion



    My problem was that the library was installed in the directories of the case 5.



    Solution




    • Uninstalling the package.


    • As I'm executing the script with Linux user forvas, I was able to reinstall the package rightly with the options 2 or 4 (in which the library is available for all Linux users) or more accurate, the option 3 (in which library is only available for Linux user forvas).







    share|improve this answer

































      2














      My problem was caused by the version of Python openssl that was in /usr/lib/python2.7/dist-packages/.



      dpkg -l | grep openssl showed:



      ii  python-openssl                                0.15.1-2build1                               all          Python 2 wrapper around the OpenSSL library


      I removed it using sudo apt-get remove python-openssl. I then ran the following to install the distribution version of pip.



      curl -o ./get-pip.py https://bootstrap.pypa.io/get-pip.py
      sudo python2 ./get-pip.py


      pip --version now displays:



      pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)


      I was then able to perform the necessary pip install I was trying to complete.






      share|improve this answer



















      • 1





        Thanks @heatfanjohn. I was in the exact same situation as yours and it works as you've written!

        – icasimpan
        Nov 22 '18 at 19:23



















      1














      I was seeing similar python stack dump on the console of my Ubuntu 16.04 VM when I tried ssh into the VM.



          SSL_ST_INIT = _lib.SSL_ST_INIT
      AttributeError: 'module' object has no attribute 'SSL_ST_INIT'


      Pip reported that pyopenssl was not installed.



      I had to do this instead:



      $ apt install --reinstall python-openssl





      share|improve this answer































        1














        I did this which helped:




        $ easy_install -U pip
        $ easy_install -U pyOpenSSL






        share|improve this answer































          1














          I had the same problem on Ubuntu 16.04, but with the following twist: when virtualenv was activated (. venv/bin/activate before running celery workers with pysolr, requests, etc in my case) - everything worked perfectly, but when I ran celery from command line using full paths, and python paths - there was a problem (and same problem running from supervisord ). Also, if important, virtualenv has been bundled elsewhere on the machine with same Ubuntu version.



          Solution was simple: adding /full/path/to/venv/bin to PATH ( as advised here https://serverfault.com/questions/331027/supervisord-how-to-append-to-path ) solved this.



          Unfortunately, I have not yet pin-pointed what kind of update caused this, but hopefully this may help someone.






          share|improve this answer

































            1














            My solution was a lot more simplistic after these other solutions not working for me. Anything I tried to install/uninstall via pip returned the same error and stacktrace.



            I ended up trying to update pip via pip3 and it worked flawlessly:



            pip3 install --upgrade pip



            I went back to using pip and everything worked correctly. I did notice that it was referencing Python 3.6 when running the pip commands though.



            # pip install pyopenssl`enter code here`
            Requirement already satisfied: pyopenssl in /usr/lib64/python3.6/site-packages (18.0.0)

            <snipped>

            Requirement already satisfied: pycparser in /usr/lib64/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography>=2.2.1->pyopenssl) (2.19)





            share|improve this answer































              0














              I saw the AttributeError: 'module' object has no attribute 'SSL_ST_INIT' error too.



              Doing



              sudo pip install pyOpenSSL==16.2.0



              resolved it for me.






              share|improve this answer































                0














                In my case, It was throwing the same error for uninstalling and upgrading. I couldn't uninstall or upgrade.



                AttributeError: 'module' object has no attribute 'SSL_ST_INIT'



                Following worked for me.



                # rm -rf /usr/lib/python2.7/site-packages/OpenSSL/
                # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-16.1.0.dist-info
                # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg
                # pip2.7 install pyopenssl
                Collecting pyopenssl
                Downloading
                .
                .
                100% |████████████████████████████████| 61kB 5.8MB/s
                Collecting cryptography>=2.2.1 (from pyopenssl)
                .
                .
                Installing collected packages: cryptography, pyopenssl
                Found existing installation: cryptography 1.7.2
                Uninstalling cryptography-1.7.2:
                Successfully uninstalled cryptography-1.7.2
                Successfully installed cryptography-2.2.2 pyopenssl-18.0.0


                WARNING: Try this only if upgrading(sudo pip install pyOpenSSL==16.2.0) or uninstalling(pip uninstall pyopenssl) doesn't help






                share|improve this answer

































                  0














                  Just in case anyone else isn't finding exactly the right incantations to make this work, as of Nov 2018 the thing that worked for me was:




                  sudo rm -rf /usr/local/lib/python2.7/dist-packages/OpenSSL/
                  sudo apt install --reinstall python-openssl



                  Good luck!






                  share|improve this answer































                    0














                    I just encountered this on my Ubuntu 16.04 host. There appears to be a version conflict between the apt repo packages for python-openssl and python-crypotgraphy, vs what someone installed manually with pip into /usr/local/python2.7/dist-packages.



                    Once it got into this state, the system standard pip couldn't execute, either. I got around the chicken-and-egg problem by manually setting a PYTHONPATH environment variable that excluded the /usr/local part of the tree thusly:



                        $ export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
                    $ /usr/bin/pip uninstall cryptography
                    $ unset PYTHONPATH


                    I acquired the above list of library directories to use with the python shell:



                        import sys
                    for p in sys.path:
                    print(p)


                    and then copying everything listed except the one /usr/local directory. Your system may have a different list in its path. Adjust accordingly.



                    I also had some manual apt-get install --reinstall python-openssl python-cryptography commands scattered in my bash history, which may or may not have been necessary.






                    share|improve this answer































                      0














                      export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
                      apt-get install --reinstall python-openssl






                      share|improve this answer
























                      • this works fine for me

                        – YoungJeXu
                        Nov 27 '18 at 3:16



















                      0














                      I had the same issue and as pip wasn't working anymore I had to do his job manually:



                      wget https://files.pythonhosted.org/packages/40/d0/8efd61531f338a89b4efa48fcf1972d870d2b67a7aea9dcf70783c8464dc/pyOpenSSL-19.0.0.tar.gz
                      tar -xzvf pyOpenSSL-19.0.0.tar.gz
                      cd pyOpenSSL-19.0.0
                      sudo python setup.py install


                      After that everything worked as expected.






                      share|improve this answer

























                        Your Answer






                        StackExchange.ifUsing("editor", function () {
                        StackExchange.using("externalEditor", function () {
                        StackExchange.using("snippets", function () {
                        StackExchange.snippets.init();
                        });
                        });
                        }, "code-snippets");

                        StackExchange.ready(function() {
                        var channelOptions = {
                        tags: "".split(" "),
                        id: "1"
                        };
                        initTagRenderer("".split(" "), "".split(" "), channelOptions);

                        StackExchange.using("externalEditor", function() {
                        // Have to fire editor after snippets, if snippets enabled
                        if (StackExchange.settings.snippets.snippetsEnabled) {
                        StackExchange.using("snippets", function() {
                        createEditor();
                        });
                        }
                        else {
                        createEditor();
                        }
                        });

                        function createEditor() {
                        StackExchange.prepareEditor({
                        heartbeatType: 'answer',
                        autoActivateHeartbeat: false,
                        convertImagesToLinks: true,
                        noModals: true,
                        showLowRepImageUploadWarning: true,
                        reputationToPostImages: 10,
                        bindNavPrevention: true,
                        postfix: "",
                        imageUploader: {
                        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                        allowUrls: true
                        },
                        onDemand: true,
                        discardSelector: ".discard-answer"
                        ,immediatelyShowMarkdownHelp:true
                        });


                        }
                        });














                        draft saved

                        draft discarded


















                        StackExchange.ready(
                        function () {
                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43267157%2fpython-attributeerror-module-object-has-no-attribute-ssl-st-init%23new-answer', 'question_page');
                        }
                        );

                        Post as a guest















                        Required, but never shown

























                        17 Answers
                        17






                        active

                        oldest

                        votes








                        17 Answers
                        17






                        active

                        oldest

                        votes









                        active

                        oldest

                        votes






                        active

                        oldest

                        votes









                        85














                        Upgrading pyopenssl with pip was not working as none of the commands related to to pip was working for me. By upgrading pyopenssl with easy_install, above problem can be solved.



                        sudo python -m easy_install --upgrade pyOpenSSL


                        credit @delimiter (Answer)






                        share|improve this answer



















                        • 1





                          Thanks! I had to restart my terminal / log back into my server after this command, and pip worked fine after that.

                          – Jarvis Johnson
                          May 1 '18 at 19:58











                        • This worked for me.

                          – Mehmet Kurtipek
                          Sep 15 '18 at 15:30











                        • meet the new error -error: Setup script exited with error: command 'gcc' failed with exit status 1

                          – brainLoop
                          Oct 8 '18 at 13:13


















                        85














                        Upgrading pyopenssl with pip was not working as none of the commands related to to pip was working for me. By upgrading pyopenssl with easy_install, above problem can be solved.



                        sudo python -m easy_install --upgrade pyOpenSSL


                        credit @delimiter (Answer)






                        share|improve this answer



















                        • 1





                          Thanks! I had to restart my terminal / log back into my server after this command, and pip worked fine after that.

                          – Jarvis Johnson
                          May 1 '18 at 19:58











                        • This worked for me.

                          – Mehmet Kurtipek
                          Sep 15 '18 at 15:30











                        • meet the new error -error: Setup script exited with error: command 'gcc' failed with exit status 1

                          – brainLoop
                          Oct 8 '18 at 13:13
















                        85












                        85








                        85







                        Upgrading pyopenssl with pip was not working as none of the commands related to to pip was working for me. By upgrading pyopenssl with easy_install, above problem can be solved.



                        sudo python -m easy_install --upgrade pyOpenSSL


                        credit @delimiter (Answer)






                        share|improve this answer













                        Upgrading pyopenssl with pip was not working as none of the commands related to to pip was working for me. By upgrading pyopenssl with easy_install, above problem can be solved.



                        sudo python -m easy_install --upgrade pyOpenSSL


                        credit @delimiter (Answer)







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Feb 1 '18 at 18:12









                        Muhammad HassanMuhammad Hassan

                        8,05621534




                        8,05621534








                        • 1





                          Thanks! I had to restart my terminal / log back into my server after this command, and pip worked fine after that.

                          – Jarvis Johnson
                          May 1 '18 at 19:58











                        • This worked for me.

                          – Mehmet Kurtipek
                          Sep 15 '18 at 15:30











                        • meet the new error -error: Setup script exited with error: command 'gcc' failed with exit status 1

                          – brainLoop
                          Oct 8 '18 at 13:13
















                        • 1





                          Thanks! I had to restart my terminal / log back into my server after this command, and pip worked fine after that.

                          – Jarvis Johnson
                          May 1 '18 at 19:58











                        • This worked for me.

                          – Mehmet Kurtipek
                          Sep 15 '18 at 15:30











                        • meet the new error -error: Setup script exited with error: command 'gcc' failed with exit status 1

                          – brainLoop
                          Oct 8 '18 at 13:13










                        1




                        1





                        Thanks! I had to restart my terminal / log back into my server after this command, and pip worked fine after that.

                        – Jarvis Johnson
                        May 1 '18 at 19:58





                        Thanks! I had to restart my terminal / log back into my server after this command, and pip worked fine after that.

                        – Jarvis Johnson
                        May 1 '18 at 19:58













                        This worked for me.

                        – Mehmet Kurtipek
                        Sep 15 '18 at 15:30





                        This worked for me.

                        – Mehmet Kurtipek
                        Sep 15 '18 at 15:30













                        meet the new error -error: Setup script exited with error: command 'gcc' failed with exit status 1

                        – brainLoop
                        Oct 8 '18 at 13:13







                        meet the new error -error: Setup script exited with error: command 'gcc' failed with exit status 1

                        – brainLoop
                        Oct 8 '18 at 13:13















                        67














                        Turned out the problem was with my installation of pyOpenSSL, pyOpenSSL-0.15.1 .



                        I did:



                        pip uninstall pyopenssl


                        and then



                        pip install pyopenssl


                        ...and my Python script worked again!






                        share|improve this answer



















                        • 24





                          i had trouble running pip itself, this solved it sudo easy_install pyOpenSSL

                          – chinmay
                          Jul 27 '17 at 9:21








                        • 2





                          Had just upgraded cryptography; your solution was sufficient in my case

                          – denvar
                          Oct 20 '17 at 12:00






                        • 3





                          In my case I had to uninstalled like this: sudo aptitude purge python-openssl because it was installed with aptitude. I think I could do the same with apt-get

                          – ChesuCR
                          May 3 '18 at 11:21






                        • 2





                          pip uninstall pyonpenssl is throwing same error

                          – brainLoop
                          Oct 8 '18 at 12:33






                        • 1





                          I got the error every time I ran pip. So did rm -rf cryptography and could run pip again.

                          – John Strood
                          Oct 31 '18 at 7:43
















                        67














                        Turned out the problem was with my installation of pyOpenSSL, pyOpenSSL-0.15.1 .



                        I did:



                        pip uninstall pyopenssl


                        and then



                        pip install pyopenssl


                        ...and my Python script worked again!






                        share|improve this answer



















                        • 24





                          i had trouble running pip itself, this solved it sudo easy_install pyOpenSSL

                          – chinmay
                          Jul 27 '17 at 9:21








                        • 2





                          Had just upgraded cryptography; your solution was sufficient in my case

                          – denvar
                          Oct 20 '17 at 12:00






                        • 3





                          In my case I had to uninstalled like this: sudo aptitude purge python-openssl because it was installed with aptitude. I think I could do the same with apt-get

                          – ChesuCR
                          May 3 '18 at 11:21






                        • 2





                          pip uninstall pyonpenssl is throwing same error

                          – brainLoop
                          Oct 8 '18 at 12:33






                        • 1





                          I got the error every time I ran pip. So did rm -rf cryptography and could run pip again.

                          – John Strood
                          Oct 31 '18 at 7:43














                        67












                        67








                        67







                        Turned out the problem was with my installation of pyOpenSSL, pyOpenSSL-0.15.1 .



                        I did:



                        pip uninstall pyopenssl


                        and then



                        pip install pyopenssl


                        ...and my Python script worked again!






                        share|improve this answer













                        Turned out the problem was with my installation of pyOpenSSL, pyOpenSSL-0.15.1 .



                        I did:



                        pip uninstall pyopenssl


                        and then



                        pip install pyopenssl


                        ...and my Python script worked again!







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Apr 6 '17 at 23:10









                        Ben WheelerBen Wheeler

                        2,98312440




                        2,98312440








                        • 24





                          i had trouble running pip itself, this solved it sudo easy_install pyOpenSSL

                          – chinmay
                          Jul 27 '17 at 9:21








                        • 2





                          Had just upgraded cryptography; your solution was sufficient in my case

                          – denvar
                          Oct 20 '17 at 12:00






                        • 3





                          In my case I had to uninstalled like this: sudo aptitude purge python-openssl because it was installed with aptitude. I think I could do the same with apt-get

                          – ChesuCR
                          May 3 '18 at 11:21






                        • 2





                          pip uninstall pyonpenssl is throwing same error

                          – brainLoop
                          Oct 8 '18 at 12:33






                        • 1





                          I got the error every time I ran pip. So did rm -rf cryptography and could run pip again.

                          – John Strood
                          Oct 31 '18 at 7:43














                        • 24





                          i had trouble running pip itself, this solved it sudo easy_install pyOpenSSL

                          – chinmay
                          Jul 27 '17 at 9:21








                        • 2





                          Had just upgraded cryptography; your solution was sufficient in my case

                          – denvar
                          Oct 20 '17 at 12:00






                        • 3





                          In my case I had to uninstalled like this: sudo aptitude purge python-openssl because it was installed with aptitude. I think I could do the same with apt-get

                          – ChesuCR
                          May 3 '18 at 11:21






                        • 2





                          pip uninstall pyonpenssl is throwing same error

                          – brainLoop
                          Oct 8 '18 at 12:33






                        • 1





                          I got the error every time I ran pip. So did rm -rf cryptography and could run pip again.

                          – John Strood
                          Oct 31 '18 at 7:43








                        24




                        24





                        i had trouble running pip itself, this solved it sudo easy_install pyOpenSSL

                        – chinmay
                        Jul 27 '17 at 9:21







                        i had trouble running pip itself, this solved it sudo easy_install pyOpenSSL

                        – chinmay
                        Jul 27 '17 at 9:21






                        2




                        2





                        Had just upgraded cryptography; your solution was sufficient in my case

                        – denvar
                        Oct 20 '17 at 12:00





                        Had just upgraded cryptography; your solution was sufficient in my case

                        – denvar
                        Oct 20 '17 at 12:00




                        3




                        3





                        In my case I had to uninstalled like this: sudo aptitude purge python-openssl because it was installed with aptitude. I think I could do the same with apt-get

                        – ChesuCR
                        May 3 '18 at 11:21





                        In my case I had to uninstalled like this: sudo aptitude purge python-openssl because it was installed with aptitude. I think I could do the same with apt-get

                        – ChesuCR
                        May 3 '18 at 11:21




                        2




                        2





                        pip uninstall pyonpenssl is throwing same error

                        – brainLoop
                        Oct 8 '18 at 12:33





                        pip uninstall pyonpenssl is throwing same error

                        – brainLoop
                        Oct 8 '18 at 12:33




                        1




                        1





                        I got the error every time I ran pip. So did rm -rf cryptography and could run pip again.

                        – John Strood
                        Oct 31 '18 at 7:43





                        I got the error every time I ran pip. So did rm -rf cryptography and could run pip again.

                        – John Strood
                        Oct 31 '18 at 7:43











                        12














                        Update your pyopenssl module:



                        $ sudo pip install -U pyopenssl





                        share|improve this answer





















                        • 1





                          Thanks, I figure that is more efficient than uninstalling and installing again.

                          – Ben Wheeler
                          Sep 7 '17 at 22:19






                        • 1





                          if you use a virtualenv you don't need sudo.

                          – Chris
                          Feb 5 '18 at 13:50
















                        12














                        Update your pyopenssl module:



                        $ sudo pip install -U pyopenssl





                        share|improve this answer





















                        • 1





                          Thanks, I figure that is more efficient than uninstalling and installing again.

                          – Ben Wheeler
                          Sep 7 '17 at 22:19






                        • 1





                          if you use a virtualenv you don't need sudo.

                          – Chris
                          Feb 5 '18 at 13:50














                        12












                        12








                        12







                        Update your pyopenssl module:



                        $ sudo pip install -U pyopenssl





                        share|improve this answer















                        Update your pyopenssl module:



                        $ sudo pip install -U pyopenssl






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Aug 24 '17 at 17:15









                        Laurent LAPORTE

                        11.2k22857




                        11.2k22857










                        answered Aug 24 '17 at 13:09









                        user197292user197292

                        24625




                        24625








                        • 1





                          Thanks, I figure that is more efficient than uninstalling and installing again.

                          – Ben Wheeler
                          Sep 7 '17 at 22:19






                        • 1





                          if you use a virtualenv you don't need sudo.

                          – Chris
                          Feb 5 '18 at 13:50














                        • 1





                          Thanks, I figure that is more efficient than uninstalling and installing again.

                          – Ben Wheeler
                          Sep 7 '17 at 22:19






                        • 1





                          if you use a virtualenv you don't need sudo.

                          – Chris
                          Feb 5 '18 at 13:50








                        1




                        1





                        Thanks, I figure that is more efficient than uninstalling and installing again.

                        – Ben Wheeler
                        Sep 7 '17 at 22:19





                        Thanks, I figure that is more efficient than uninstalling and installing again.

                        – Ben Wheeler
                        Sep 7 '17 at 22:19




                        1




                        1





                        if you use a virtualenv you don't need sudo.

                        – Chris
                        Feb 5 '18 at 13:50





                        if you use a virtualenv you don't need sudo.

                        – Chris
                        Feb 5 '18 at 13:50











                        8














                        I experienced the same issue recently and after few hours investigation, I found out that it was caused by New cryptography 2.0 upgrade. This upgrade will break many packages using pyopenssl (like Sentry, Google Analytics and etc). Just downgrade it to 1.9 will solve the problem.



                        Be cautious if you are using "pip install -U", it will automatically upgrade packages that are not listed in requirements.txt.






                        share|improve this answer
























                        • Thanks, this worked. Upgrading pyopenssl wasn't sufficient for me.

                          – r11
                          Oct 16 '17 at 6:23
















                        8














                        I experienced the same issue recently and after few hours investigation, I found out that it was caused by New cryptography 2.0 upgrade. This upgrade will break many packages using pyopenssl (like Sentry, Google Analytics and etc). Just downgrade it to 1.9 will solve the problem.



                        Be cautious if you are using "pip install -U", it will automatically upgrade packages that are not listed in requirements.txt.






                        share|improve this answer
























                        • Thanks, this worked. Upgrading pyopenssl wasn't sufficient for me.

                          – r11
                          Oct 16 '17 at 6:23














                        8












                        8








                        8







                        I experienced the same issue recently and after few hours investigation, I found out that it was caused by New cryptography 2.0 upgrade. This upgrade will break many packages using pyopenssl (like Sentry, Google Analytics and etc). Just downgrade it to 1.9 will solve the problem.



                        Be cautious if you are using "pip install -U", it will automatically upgrade packages that are not listed in requirements.txt.






                        share|improve this answer













                        I experienced the same issue recently and after few hours investigation, I found out that it was caused by New cryptography 2.0 upgrade. This upgrade will break many packages using pyopenssl (like Sentry, Google Analytics and etc). Just downgrade it to 1.9 will solve the problem.



                        Be cautious if you are using "pip install -U", it will automatically upgrade packages that are not listed in requirements.txt.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jul 24 '17 at 18:54









                        Fei XieFei Xie

                        10111




                        10111













                        • Thanks, this worked. Upgrading pyopenssl wasn't sufficient for me.

                          – r11
                          Oct 16 '17 at 6:23



















                        • Thanks, this worked. Upgrading pyopenssl wasn't sufficient for me.

                          – r11
                          Oct 16 '17 at 6:23

















                        Thanks, this worked. Upgrading pyopenssl wasn't sufficient for me.

                        – r11
                        Oct 16 '17 at 6:23





                        Thanks, this worked. Upgrading pyopenssl wasn't sufficient for me.

                        – r11
                        Oct 16 '17 at 6:23











                        6














                        I had a similar error:



                            from OpenSSL import rand, crypto, SSL
                        File "/usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py", line 112, in <module>
                        SSL_ST_INIT = _lib.SSL_ST_INIT
                        AttributeError: module 'lib' has no attribute 'SSL_ST_INIT'


                        and none of the other answers could fix it, because pip could not install anything. Instead, what I did was this from the terminal first:



                        sudo rm -r /usr/local/lib/python3.5/dist-packages/OpenSSL


                        Then reinstalled pyopenssl with pip:



                        sudo pip install pyopenssl


                        and everything was gravy.






                        share|improve this answer




























                          6














                          I had a similar error:



                              from OpenSSL import rand, crypto, SSL
                          File "/usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py", line 112, in <module>
                          SSL_ST_INIT = _lib.SSL_ST_INIT
                          AttributeError: module 'lib' has no attribute 'SSL_ST_INIT'


                          and none of the other answers could fix it, because pip could not install anything. Instead, what I did was this from the terminal first:



                          sudo rm -r /usr/local/lib/python3.5/dist-packages/OpenSSL


                          Then reinstalled pyopenssl with pip:



                          sudo pip install pyopenssl


                          and everything was gravy.






                          share|improve this answer


























                            6












                            6








                            6







                            I had a similar error:



                                from OpenSSL import rand, crypto, SSL
                            File "/usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py", line 112, in <module>
                            SSL_ST_INIT = _lib.SSL_ST_INIT
                            AttributeError: module 'lib' has no attribute 'SSL_ST_INIT'


                            and none of the other answers could fix it, because pip could not install anything. Instead, what I did was this from the terminal first:



                            sudo rm -r /usr/local/lib/python3.5/dist-packages/OpenSSL


                            Then reinstalled pyopenssl with pip:



                            sudo pip install pyopenssl


                            and everything was gravy.






                            share|improve this answer













                            I had a similar error:



                                from OpenSSL import rand, crypto, SSL
                            File "/usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py", line 112, in <module>
                            SSL_ST_INIT = _lib.SSL_ST_INIT
                            AttributeError: module 'lib' has no attribute 'SSL_ST_INIT'


                            and none of the other answers could fix it, because pip could not install anything. Instead, what I did was this from the terminal first:



                            sudo rm -r /usr/local/lib/python3.5/dist-packages/OpenSSL


                            Then reinstalled pyopenssl with pip:



                            sudo pip install pyopenssl


                            and everything was gravy.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Sep 19 '18 at 4:42









                            wordsforthewisewordsforthewise

                            3,43622951




                            3,43622951























                                2














                                In my case, the problem was that the package was installed in root directories, and I was executing the script which asked for pyopenssl with my Linux user forvas. And that user can't use the libraries installed in root.



                                So first I had to remove the package with aptitude or apt-get.



                                sudo aptitude purge python-openssl


                                Therefore, I had to install the package again, but taking into account the user who is executing the script which is asking for the library. Take a look to where the library is installed depending on the Linux user and the argument --user of pip.



                                Case 1



                                forvas@server:$ pip install pyopenssl



                                Could not install packages due to an EnvironmentError:



                                [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/OpenSSL'



                                Consider using the --user option or check the permissions.




                                Case 2



                                forvas@server:$ sudo pip install pyopenssl



                                /usr/local/lib/python2.7/dist-packages/OpenSSL/*



                                /usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*




                                Case 3



                                forvas@server:$ sudo pip install --user pyopenssl



                                /home/forvas/.local/lib/python2.7/site-packages/OpenSSL/*



                                /home/forvas/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*




                                Case 4



                                root@server:$ pip install pyopenssl



                                /usr/local/lib/python2.7/dist-packages/OpenSSL/*



                                /usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*




                                Case 5



                                root@server:$ pip install --user pyopenssl



                                /root/.local/lib/python2.7/site-packages/OpenSSL/*



                                /root/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*




                                Conclusion



                                My problem was that the library was installed in the directories of the case 5.



                                Solution




                                • Uninstalling the package.


                                • As I'm executing the script with Linux user forvas, I was able to reinstall the package rightly with the options 2 or 4 (in which the library is available for all Linux users) or more accurate, the option 3 (in which library is only available for Linux user forvas).







                                share|improve this answer






























                                  2














                                  In my case, the problem was that the package was installed in root directories, and I was executing the script which asked for pyopenssl with my Linux user forvas. And that user can't use the libraries installed in root.



                                  So first I had to remove the package with aptitude or apt-get.



                                  sudo aptitude purge python-openssl


                                  Therefore, I had to install the package again, but taking into account the user who is executing the script which is asking for the library. Take a look to where the library is installed depending on the Linux user and the argument --user of pip.



                                  Case 1



                                  forvas@server:$ pip install pyopenssl



                                  Could not install packages due to an EnvironmentError:



                                  [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/OpenSSL'



                                  Consider using the --user option or check the permissions.




                                  Case 2



                                  forvas@server:$ sudo pip install pyopenssl



                                  /usr/local/lib/python2.7/dist-packages/OpenSSL/*



                                  /usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*




                                  Case 3



                                  forvas@server:$ sudo pip install --user pyopenssl



                                  /home/forvas/.local/lib/python2.7/site-packages/OpenSSL/*



                                  /home/forvas/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*




                                  Case 4



                                  root@server:$ pip install pyopenssl



                                  /usr/local/lib/python2.7/dist-packages/OpenSSL/*



                                  /usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*




                                  Case 5



                                  root@server:$ pip install --user pyopenssl



                                  /root/.local/lib/python2.7/site-packages/OpenSSL/*



                                  /root/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*




                                  Conclusion



                                  My problem was that the library was installed in the directories of the case 5.



                                  Solution




                                  • Uninstalling the package.


                                  • As I'm executing the script with Linux user forvas, I was able to reinstall the package rightly with the options 2 or 4 (in which the library is available for all Linux users) or more accurate, the option 3 (in which library is only available for Linux user forvas).







                                  share|improve this answer




























                                    2












                                    2








                                    2







                                    In my case, the problem was that the package was installed in root directories, and I was executing the script which asked for pyopenssl with my Linux user forvas. And that user can't use the libraries installed in root.



                                    So first I had to remove the package with aptitude or apt-get.



                                    sudo aptitude purge python-openssl


                                    Therefore, I had to install the package again, but taking into account the user who is executing the script which is asking for the library. Take a look to where the library is installed depending on the Linux user and the argument --user of pip.



                                    Case 1



                                    forvas@server:$ pip install pyopenssl



                                    Could not install packages due to an EnvironmentError:



                                    [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/OpenSSL'



                                    Consider using the --user option or check the permissions.




                                    Case 2



                                    forvas@server:$ sudo pip install pyopenssl



                                    /usr/local/lib/python2.7/dist-packages/OpenSSL/*



                                    /usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*




                                    Case 3



                                    forvas@server:$ sudo pip install --user pyopenssl



                                    /home/forvas/.local/lib/python2.7/site-packages/OpenSSL/*



                                    /home/forvas/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*




                                    Case 4



                                    root@server:$ pip install pyopenssl



                                    /usr/local/lib/python2.7/dist-packages/OpenSSL/*



                                    /usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*




                                    Case 5



                                    root@server:$ pip install --user pyopenssl



                                    /root/.local/lib/python2.7/site-packages/OpenSSL/*



                                    /root/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*




                                    Conclusion



                                    My problem was that the library was installed in the directories of the case 5.



                                    Solution




                                    • Uninstalling the package.


                                    • As I'm executing the script with Linux user forvas, I was able to reinstall the package rightly with the options 2 or 4 (in which the library is available for all Linux users) or more accurate, the option 3 (in which library is only available for Linux user forvas).







                                    share|improve this answer















                                    In my case, the problem was that the package was installed in root directories, and I was executing the script which asked for pyopenssl with my Linux user forvas. And that user can't use the libraries installed in root.



                                    So first I had to remove the package with aptitude or apt-get.



                                    sudo aptitude purge python-openssl


                                    Therefore, I had to install the package again, but taking into account the user who is executing the script which is asking for the library. Take a look to where the library is installed depending on the Linux user and the argument --user of pip.



                                    Case 1



                                    forvas@server:$ pip install pyopenssl



                                    Could not install packages due to an EnvironmentError:



                                    [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/OpenSSL'



                                    Consider using the --user option or check the permissions.




                                    Case 2



                                    forvas@server:$ sudo pip install pyopenssl



                                    /usr/local/lib/python2.7/dist-packages/OpenSSL/*



                                    /usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*




                                    Case 3



                                    forvas@server:$ sudo pip install --user pyopenssl



                                    /home/forvas/.local/lib/python2.7/site-packages/OpenSSL/*



                                    /home/forvas/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*




                                    Case 4



                                    root@server:$ pip install pyopenssl



                                    /usr/local/lib/python2.7/dist-packages/OpenSSL/*



                                    /usr/local/lib/python2.7/dist-packages/pyOpenSSL-17.5.0.dist-info/*




                                    Case 5



                                    root@server:$ pip install --user pyopenssl



                                    /root/.local/lib/python2.7/site-packages/OpenSSL/*



                                    /root/.local/lib/python2.7/site-packages/pyOpenSSL-17.5.0.dist-info/*




                                    Conclusion



                                    My problem was that the library was installed in the directories of the case 5.



                                    Solution




                                    • Uninstalling the package.


                                    • As I'm executing the script with Linux user forvas, I was able to reinstall the package rightly with the options 2 or 4 (in which the library is available for all Linux users) or more accurate, the option 3 (in which library is only available for Linux user forvas).








                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited May 3 '18 at 12:35

























                                    answered Apr 25 '18 at 11:22









                                    forvasforvas

                                    5,40162980




                                    5,40162980























                                        2














                                        My problem was caused by the version of Python openssl that was in /usr/lib/python2.7/dist-packages/.



                                        dpkg -l | grep openssl showed:



                                        ii  python-openssl                                0.15.1-2build1                               all          Python 2 wrapper around the OpenSSL library


                                        I removed it using sudo apt-get remove python-openssl. I then ran the following to install the distribution version of pip.



                                        curl -o ./get-pip.py https://bootstrap.pypa.io/get-pip.py
                                        sudo python2 ./get-pip.py


                                        pip --version now displays:



                                        pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)


                                        I was then able to perform the necessary pip install I was trying to complete.






                                        share|improve this answer



















                                        • 1





                                          Thanks @heatfanjohn. I was in the exact same situation as yours and it works as you've written!

                                          – icasimpan
                                          Nov 22 '18 at 19:23
















                                        2














                                        My problem was caused by the version of Python openssl that was in /usr/lib/python2.7/dist-packages/.



                                        dpkg -l | grep openssl showed:



                                        ii  python-openssl                                0.15.1-2build1                               all          Python 2 wrapper around the OpenSSL library


                                        I removed it using sudo apt-get remove python-openssl. I then ran the following to install the distribution version of pip.



                                        curl -o ./get-pip.py https://bootstrap.pypa.io/get-pip.py
                                        sudo python2 ./get-pip.py


                                        pip --version now displays:



                                        pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)


                                        I was then able to perform the necessary pip install I was trying to complete.






                                        share|improve this answer



















                                        • 1





                                          Thanks @heatfanjohn. I was in the exact same situation as yours and it works as you've written!

                                          – icasimpan
                                          Nov 22 '18 at 19:23














                                        2












                                        2








                                        2







                                        My problem was caused by the version of Python openssl that was in /usr/lib/python2.7/dist-packages/.



                                        dpkg -l | grep openssl showed:



                                        ii  python-openssl                                0.15.1-2build1                               all          Python 2 wrapper around the OpenSSL library


                                        I removed it using sudo apt-get remove python-openssl. I then ran the following to install the distribution version of pip.



                                        curl -o ./get-pip.py https://bootstrap.pypa.io/get-pip.py
                                        sudo python2 ./get-pip.py


                                        pip --version now displays:



                                        pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)


                                        I was then able to perform the necessary pip install I was trying to complete.






                                        share|improve this answer













                                        My problem was caused by the version of Python openssl that was in /usr/lib/python2.7/dist-packages/.



                                        dpkg -l | grep openssl showed:



                                        ii  python-openssl                                0.15.1-2build1                               all          Python 2 wrapper around the OpenSSL library


                                        I removed it using sudo apt-get remove python-openssl. I then ran the following to install the distribution version of pip.



                                        curl -o ./get-pip.py https://bootstrap.pypa.io/get-pip.py
                                        sudo python2 ./get-pip.py


                                        pip --version now displays:



                                        pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)


                                        I was then able to perform the necessary pip install I was trying to complete.







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Aug 2 '18 at 16:08









                                        HeatfanJohnHeatfanJohn

                                        4,89822338




                                        4,89822338








                                        • 1





                                          Thanks @heatfanjohn. I was in the exact same situation as yours and it works as you've written!

                                          – icasimpan
                                          Nov 22 '18 at 19:23














                                        • 1





                                          Thanks @heatfanjohn. I was in the exact same situation as yours and it works as you've written!

                                          – icasimpan
                                          Nov 22 '18 at 19:23








                                        1




                                        1





                                        Thanks @heatfanjohn. I was in the exact same situation as yours and it works as you've written!

                                        – icasimpan
                                        Nov 22 '18 at 19:23





                                        Thanks @heatfanjohn. I was in the exact same situation as yours and it works as you've written!

                                        – icasimpan
                                        Nov 22 '18 at 19:23











                                        1














                                        I was seeing similar python stack dump on the console of my Ubuntu 16.04 VM when I tried ssh into the VM.



                                            SSL_ST_INIT = _lib.SSL_ST_INIT
                                        AttributeError: 'module' object has no attribute 'SSL_ST_INIT'


                                        Pip reported that pyopenssl was not installed.



                                        I had to do this instead:



                                        $ apt install --reinstall python-openssl





                                        share|improve this answer




























                                          1














                                          I was seeing similar python stack dump on the console of my Ubuntu 16.04 VM when I tried ssh into the VM.



                                              SSL_ST_INIT = _lib.SSL_ST_INIT
                                          AttributeError: 'module' object has no attribute 'SSL_ST_INIT'


                                          Pip reported that pyopenssl was not installed.



                                          I had to do this instead:



                                          $ apt install --reinstall python-openssl





                                          share|improve this answer


























                                            1












                                            1








                                            1







                                            I was seeing similar python stack dump on the console of my Ubuntu 16.04 VM when I tried ssh into the VM.



                                                SSL_ST_INIT = _lib.SSL_ST_INIT
                                            AttributeError: 'module' object has no attribute 'SSL_ST_INIT'


                                            Pip reported that pyopenssl was not installed.



                                            I had to do this instead:



                                            $ apt install --reinstall python-openssl





                                            share|improve this answer













                                            I was seeing similar python stack dump on the console of my Ubuntu 16.04 VM when I tried ssh into the VM.



                                                SSL_ST_INIT = _lib.SSL_ST_INIT
                                            AttributeError: 'module' object has no attribute 'SSL_ST_INIT'


                                            Pip reported that pyopenssl was not installed.



                                            I had to do this instead:



                                            $ apt install --reinstall python-openssl






                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered May 9 '18 at 22:39









                                            Deepak MohantyDeepak Mohanty

                                            811




                                            811























                                                1














                                                I did this which helped:




                                                $ easy_install -U pip
                                                $ easy_install -U pyOpenSSL






                                                share|improve this answer




























                                                  1














                                                  I did this which helped:




                                                  $ easy_install -U pip
                                                  $ easy_install -U pyOpenSSL






                                                  share|improve this answer


























                                                    1












                                                    1








                                                    1







                                                    I did this which helped:




                                                    $ easy_install -U pip
                                                    $ easy_install -U pyOpenSSL






                                                    share|improve this answer













                                                    I did this which helped:




                                                    $ easy_install -U pip
                                                    $ easy_install -U pyOpenSSL







                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered Jul 1 '18 at 17:34









                                                    felix021felix021

                                                    5731718




                                                    5731718























                                                        1














                                                        I had the same problem on Ubuntu 16.04, but with the following twist: when virtualenv was activated (. venv/bin/activate before running celery workers with pysolr, requests, etc in my case) - everything worked perfectly, but when I ran celery from command line using full paths, and python paths - there was a problem (and same problem running from supervisord ). Also, if important, virtualenv has been bundled elsewhere on the machine with same Ubuntu version.



                                                        Solution was simple: adding /full/path/to/venv/bin to PATH ( as advised here https://serverfault.com/questions/331027/supervisord-how-to-append-to-path ) solved this.



                                                        Unfortunately, I have not yet pin-pointed what kind of update caused this, but hopefully this may help someone.






                                                        share|improve this answer






























                                                          1














                                                          I had the same problem on Ubuntu 16.04, but with the following twist: when virtualenv was activated (. venv/bin/activate before running celery workers with pysolr, requests, etc in my case) - everything worked perfectly, but when I ran celery from command line using full paths, and python paths - there was a problem (and same problem running from supervisord ). Also, if important, virtualenv has been bundled elsewhere on the machine with same Ubuntu version.



                                                          Solution was simple: adding /full/path/to/venv/bin to PATH ( as advised here https://serverfault.com/questions/331027/supervisord-how-to-append-to-path ) solved this.



                                                          Unfortunately, I have not yet pin-pointed what kind of update caused this, but hopefully this may help someone.






                                                          share|improve this answer




























                                                            1












                                                            1








                                                            1







                                                            I had the same problem on Ubuntu 16.04, but with the following twist: when virtualenv was activated (. venv/bin/activate before running celery workers with pysolr, requests, etc in my case) - everything worked perfectly, but when I ran celery from command line using full paths, and python paths - there was a problem (and same problem running from supervisord ). Also, if important, virtualenv has been bundled elsewhere on the machine with same Ubuntu version.



                                                            Solution was simple: adding /full/path/to/venv/bin to PATH ( as advised here https://serverfault.com/questions/331027/supervisord-how-to-append-to-path ) solved this.



                                                            Unfortunately, I have not yet pin-pointed what kind of update caused this, but hopefully this may help someone.






                                                            share|improve this answer















                                                            I had the same problem on Ubuntu 16.04, but with the following twist: when virtualenv was activated (. venv/bin/activate before running celery workers with pysolr, requests, etc in my case) - everything worked perfectly, but when I ran celery from command line using full paths, and python paths - there was a problem (and same problem running from supervisord ). Also, if important, virtualenv has been bundled elsewhere on the machine with same Ubuntu version.



                                                            Solution was simple: adding /full/path/to/venv/bin to PATH ( as advised here https://serverfault.com/questions/331027/supervisord-how-to-append-to-path ) solved this.



                                                            Unfortunately, I have not yet pin-pointed what kind of update caused this, but hopefully this may help someone.







                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited Jul 29 '18 at 5:24

























                                                            answered Mar 7 '18 at 14:24









                                                            Roman SusiRoman Susi

                                                            2,40921732




                                                            2,40921732























                                                                1














                                                                My solution was a lot more simplistic after these other solutions not working for me. Anything I tried to install/uninstall via pip returned the same error and stacktrace.



                                                                I ended up trying to update pip via pip3 and it worked flawlessly:



                                                                pip3 install --upgrade pip



                                                                I went back to using pip and everything worked correctly. I did notice that it was referencing Python 3.6 when running the pip commands though.



                                                                # pip install pyopenssl`enter code here`
                                                                Requirement already satisfied: pyopenssl in /usr/lib64/python3.6/site-packages (18.0.0)

                                                                <snipped>

                                                                Requirement already satisfied: pycparser in /usr/lib64/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography>=2.2.1->pyopenssl) (2.19)





                                                                share|improve this answer




























                                                                  1














                                                                  My solution was a lot more simplistic after these other solutions not working for me. Anything I tried to install/uninstall via pip returned the same error and stacktrace.



                                                                  I ended up trying to update pip via pip3 and it worked flawlessly:



                                                                  pip3 install --upgrade pip



                                                                  I went back to using pip and everything worked correctly. I did notice that it was referencing Python 3.6 when running the pip commands though.



                                                                  # pip install pyopenssl`enter code here`
                                                                  Requirement already satisfied: pyopenssl in /usr/lib64/python3.6/site-packages (18.0.0)

                                                                  <snipped>

                                                                  Requirement already satisfied: pycparser in /usr/lib64/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography>=2.2.1->pyopenssl) (2.19)





                                                                  share|improve this answer


























                                                                    1












                                                                    1








                                                                    1







                                                                    My solution was a lot more simplistic after these other solutions not working for me. Anything I tried to install/uninstall via pip returned the same error and stacktrace.



                                                                    I ended up trying to update pip via pip3 and it worked flawlessly:



                                                                    pip3 install --upgrade pip



                                                                    I went back to using pip and everything worked correctly. I did notice that it was referencing Python 3.6 when running the pip commands though.



                                                                    # pip install pyopenssl`enter code here`
                                                                    Requirement already satisfied: pyopenssl in /usr/lib64/python3.6/site-packages (18.0.0)

                                                                    <snipped>

                                                                    Requirement already satisfied: pycparser in /usr/lib64/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography>=2.2.1->pyopenssl) (2.19)





                                                                    share|improve this answer













                                                                    My solution was a lot more simplistic after these other solutions not working for me. Anything I tried to install/uninstall via pip returned the same error and stacktrace.



                                                                    I ended up trying to update pip via pip3 and it worked flawlessly:



                                                                    pip3 install --upgrade pip



                                                                    I went back to using pip and everything worked correctly. I did notice that it was referencing Python 3.6 when running the pip commands though.



                                                                    # pip install pyopenssl`enter code here`
                                                                    Requirement already satisfied: pyopenssl in /usr/lib64/python3.6/site-packages (18.0.0)

                                                                    <snipped>

                                                                    Requirement already satisfied: pycparser in /usr/lib64/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography>=2.2.1->pyopenssl) (2.19)






                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered Dec 31 '18 at 16:29









                                                                    LesterCovaxLesterCovax

                                                                    113




                                                                    113























                                                                        0














                                                                        I saw the AttributeError: 'module' object has no attribute 'SSL_ST_INIT' error too.



                                                                        Doing



                                                                        sudo pip install pyOpenSSL==16.2.0



                                                                        resolved it for me.






                                                                        share|improve this answer




























                                                                          0














                                                                          I saw the AttributeError: 'module' object has no attribute 'SSL_ST_INIT' error too.



                                                                          Doing



                                                                          sudo pip install pyOpenSSL==16.2.0



                                                                          resolved it for me.






                                                                          share|improve this answer


























                                                                            0












                                                                            0








                                                                            0







                                                                            I saw the AttributeError: 'module' object has no attribute 'SSL_ST_INIT' error too.



                                                                            Doing



                                                                            sudo pip install pyOpenSSL==16.2.0



                                                                            resolved it for me.






                                                                            share|improve this answer













                                                                            I saw the AttributeError: 'module' object has no attribute 'SSL_ST_INIT' error too.



                                                                            Doing



                                                                            sudo pip install pyOpenSSL==16.2.0



                                                                            resolved it for me.







                                                                            share|improve this answer












                                                                            share|improve this answer



                                                                            share|improve this answer










                                                                            answered Mar 8 '18 at 23:17









                                                                            Vikram HosakoteVikram Hosakote

                                                                            1,093311




                                                                            1,093311























                                                                                0














                                                                                In my case, It was throwing the same error for uninstalling and upgrading. I couldn't uninstall or upgrade.



                                                                                AttributeError: 'module' object has no attribute 'SSL_ST_INIT'



                                                                                Following worked for me.



                                                                                # rm -rf /usr/lib/python2.7/site-packages/OpenSSL/
                                                                                # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-16.1.0.dist-info
                                                                                # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg
                                                                                # pip2.7 install pyopenssl
                                                                                Collecting pyopenssl
                                                                                Downloading
                                                                                .
                                                                                .
                                                                                100% |████████████████████████████████| 61kB 5.8MB/s
                                                                                Collecting cryptography>=2.2.1 (from pyopenssl)
                                                                                .
                                                                                .
                                                                                Installing collected packages: cryptography, pyopenssl
                                                                                Found existing installation: cryptography 1.7.2
                                                                                Uninstalling cryptography-1.7.2:
                                                                                Successfully uninstalled cryptography-1.7.2
                                                                                Successfully installed cryptography-2.2.2 pyopenssl-18.0.0


                                                                                WARNING: Try this only if upgrading(sudo pip install pyOpenSSL==16.2.0) or uninstalling(pip uninstall pyopenssl) doesn't help






                                                                                share|improve this answer






























                                                                                  0














                                                                                  In my case, It was throwing the same error for uninstalling and upgrading. I couldn't uninstall or upgrade.



                                                                                  AttributeError: 'module' object has no attribute 'SSL_ST_INIT'



                                                                                  Following worked for me.



                                                                                  # rm -rf /usr/lib/python2.7/site-packages/OpenSSL/
                                                                                  # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-16.1.0.dist-info
                                                                                  # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg
                                                                                  # pip2.7 install pyopenssl
                                                                                  Collecting pyopenssl
                                                                                  Downloading
                                                                                  .
                                                                                  .
                                                                                  100% |████████████████████████████████| 61kB 5.8MB/s
                                                                                  Collecting cryptography>=2.2.1 (from pyopenssl)
                                                                                  .
                                                                                  .
                                                                                  Installing collected packages: cryptography, pyopenssl
                                                                                  Found existing installation: cryptography 1.7.2
                                                                                  Uninstalling cryptography-1.7.2:
                                                                                  Successfully uninstalled cryptography-1.7.2
                                                                                  Successfully installed cryptography-2.2.2 pyopenssl-18.0.0


                                                                                  WARNING: Try this only if upgrading(sudo pip install pyOpenSSL==16.2.0) or uninstalling(pip uninstall pyopenssl) doesn't help






                                                                                  share|improve this answer




























                                                                                    0












                                                                                    0








                                                                                    0







                                                                                    In my case, It was throwing the same error for uninstalling and upgrading. I couldn't uninstall or upgrade.



                                                                                    AttributeError: 'module' object has no attribute 'SSL_ST_INIT'



                                                                                    Following worked for me.



                                                                                    # rm -rf /usr/lib/python2.7/site-packages/OpenSSL/
                                                                                    # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-16.1.0.dist-info
                                                                                    # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg
                                                                                    # pip2.7 install pyopenssl
                                                                                    Collecting pyopenssl
                                                                                    Downloading
                                                                                    .
                                                                                    .
                                                                                    100% |████████████████████████████████| 61kB 5.8MB/s
                                                                                    Collecting cryptography>=2.2.1 (from pyopenssl)
                                                                                    .
                                                                                    .
                                                                                    Installing collected packages: cryptography, pyopenssl
                                                                                    Found existing installation: cryptography 1.7.2
                                                                                    Uninstalling cryptography-1.7.2:
                                                                                    Successfully uninstalled cryptography-1.7.2
                                                                                    Successfully installed cryptography-2.2.2 pyopenssl-18.0.0


                                                                                    WARNING: Try this only if upgrading(sudo pip install pyOpenSSL==16.2.0) or uninstalling(pip uninstall pyopenssl) doesn't help






                                                                                    share|improve this answer















                                                                                    In my case, It was throwing the same error for uninstalling and upgrading. I couldn't uninstall or upgrade.



                                                                                    AttributeError: 'module' object has no attribute 'SSL_ST_INIT'



                                                                                    Following worked for me.



                                                                                    # rm -rf /usr/lib/python2.7/site-packages/OpenSSL/
                                                                                    # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-16.1.0.dist-info
                                                                                    # rm -rf /usr/lib/python2.7/site-packages/pyOpenSSL-18.0.0-py2.7.egg
                                                                                    # pip2.7 install pyopenssl
                                                                                    Collecting pyopenssl
                                                                                    Downloading
                                                                                    .
                                                                                    .
                                                                                    100% |████████████████████████████████| 61kB 5.8MB/s
                                                                                    Collecting cryptography>=2.2.1 (from pyopenssl)
                                                                                    .
                                                                                    .
                                                                                    Installing collected packages: cryptography, pyopenssl
                                                                                    Found existing installation: cryptography 1.7.2
                                                                                    Uninstalling cryptography-1.7.2:
                                                                                    Successfully uninstalled cryptography-1.7.2
                                                                                    Successfully installed cryptography-2.2.2 pyopenssl-18.0.0


                                                                                    WARNING: Try this only if upgrading(sudo pip install pyOpenSSL==16.2.0) or uninstalling(pip uninstall pyopenssl) doesn't help







                                                                                    share|improve this answer














                                                                                    share|improve this answer



                                                                                    share|improve this answer








                                                                                    edited May 25 '18 at 22:59

























                                                                                    answered May 25 '18 at 22:53









                                                                                    f-societyf-society

                                                                                    1,4391512




                                                                                    1,4391512























                                                                                        0














                                                                                        Just in case anyone else isn't finding exactly the right incantations to make this work, as of Nov 2018 the thing that worked for me was:




                                                                                        sudo rm -rf /usr/local/lib/python2.7/dist-packages/OpenSSL/
                                                                                        sudo apt install --reinstall python-openssl



                                                                                        Good luck!






                                                                                        share|improve this answer




























                                                                                          0














                                                                                          Just in case anyone else isn't finding exactly the right incantations to make this work, as of Nov 2018 the thing that worked for me was:




                                                                                          sudo rm -rf /usr/local/lib/python2.7/dist-packages/OpenSSL/
                                                                                          sudo apt install --reinstall python-openssl



                                                                                          Good luck!






                                                                                          share|improve this answer


























                                                                                            0












                                                                                            0








                                                                                            0







                                                                                            Just in case anyone else isn't finding exactly the right incantations to make this work, as of Nov 2018 the thing that worked for me was:




                                                                                            sudo rm -rf /usr/local/lib/python2.7/dist-packages/OpenSSL/
                                                                                            sudo apt install --reinstall python-openssl



                                                                                            Good luck!






                                                                                            share|improve this answer













                                                                                            Just in case anyone else isn't finding exactly the right incantations to make this work, as of Nov 2018 the thing that worked for me was:




                                                                                            sudo rm -rf /usr/local/lib/python2.7/dist-packages/OpenSSL/
                                                                                            sudo apt install --reinstall python-openssl



                                                                                            Good luck!







                                                                                            share|improve this answer












                                                                                            share|improve this answer



                                                                                            share|improve this answer










                                                                                            answered Nov 7 '18 at 18:16









                                                                                            brianpgersonbrianpgerson

                                                                                            135




                                                                                            135























                                                                                                0














                                                                                                I just encountered this on my Ubuntu 16.04 host. There appears to be a version conflict between the apt repo packages for python-openssl and python-crypotgraphy, vs what someone installed manually with pip into /usr/local/python2.7/dist-packages.



                                                                                                Once it got into this state, the system standard pip couldn't execute, either. I got around the chicken-and-egg problem by manually setting a PYTHONPATH environment variable that excluded the /usr/local part of the tree thusly:



                                                                                                    $ export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
                                                                                                $ /usr/bin/pip uninstall cryptography
                                                                                                $ unset PYTHONPATH


                                                                                                I acquired the above list of library directories to use with the python shell:



                                                                                                    import sys
                                                                                                for p in sys.path:
                                                                                                print(p)


                                                                                                and then copying everything listed except the one /usr/local directory. Your system may have a different list in its path. Adjust accordingly.



                                                                                                I also had some manual apt-get install --reinstall python-openssl python-cryptography commands scattered in my bash history, which may or may not have been necessary.






                                                                                                share|improve this answer




























                                                                                                  0














                                                                                                  I just encountered this on my Ubuntu 16.04 host. There appears to be a version conflict between the apt repo packages for python-openssl and python-crypotgraphy, vs what someone installed manually with pip into /usr/local/python2.7/dist-packages.



                                                                                                  Once it got into this state, the system standard pip couldn't execute, either. I got around the chicken-and-egg problem by manually setting a PYTHONPATH environment variable that excluded the /usr/local part of the tree thusly:



                                                                                                      $ export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
                                                                                                  $ /usr/bin/pip uninstall cryptography
                                                                                                  $ unset PYTHONPATH


                                                                                                  I acquired the above list of library directories to use with the python shell:



                                                                                                      import sys
                                                                                                  for p in sys.path:
                                                                                                  print(p)


                                                                                                  and then copying everything listed except the one /usr/local directory. Your system may have a different list in its path. Adjust accordingly.



                                                                                                  I also had some manual apt-get install --reinstall python-openssl python-cryptography commands scattered in my bash history, which may or may not have been necessary.






                                                                                                  share|improve this answer


























                                                                                                    0












                                                                                                    0








                                                                                                    0







                                                                                                    I just encountered this on my Ubuntu 16.04 host. There appears to be a version conflict between the apt repo packages for python-openssl and python-crypotgraphy, vs what someone installed manually with pip into /usr/local/python2.7/dist-packages.



                                                                                                    Once it got into this state, the system standard pip couldn't execute, either. I got around the chicken-and-egg problem by manually setting a PYTHONPATH environment variable that excluded the /usr/local part of the tree thusly:



                                                                                                        $ export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
                                                                                                    $ /usr/bin/pip uninstall cryptography
                                                                                                    $ unset PYTHONPATH


                                                                                                    I acquired the above list of library directories to use with the python shell:



                                                                                                        import sys
                                                                                                    for p in sys.path:
                                                                                                    print(p)


                                                                                                    and then copying everything listed except the one /usr/local directory. Your system may have a different list in its path. Adjust accordingly.



                                                                                                    I also had some manual apt-get install --reinstall python-openssl python-cryptography commands scattered in my bash history, which may or may not have been necessary.






                                                                                                    share|improve this answer













                                                                                                    I just encountered this on my Ubuntu 16.04 host. There appears to be a version conflict between the apt repo packages for python-openssl and python-crypotgraphy, vs what someone installed manually with pip into /usr/local/python2.7/dist-packages.



                                                                                                    Once it got into this state, the system standard pip couldn't execute, either. I got around the chicken-and-egg problem by manually setting a PYTHONPATH environment variable that excluded the /usr/local part of the tree thusly:



                                                                                                        $ export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
                                                                                                    $ /usr/bin/pip uninstall cryptography
                                                                                                    $ unset PYTHONPATH


                                                                                                    I acquired the above list of library directories to use with the python shell:



                                                                                                        import sys
                                                                                                    for p in sys.path:
                                                                                                    print(p)


                                                                                                    and then copying everything listed except the one /usr/local directory. Your system may have a different list in its path. Adjust accordingly.



                                                                                                    I also had some manual apt-get install --reinstall python-openssl python-cryptography commands scattered in my bash history, which may or may not have been necessary.







                                                                                                    share|improve this answer












                                                                                                    share|improve this answer



                                                                                                    share|improve this answer










                                                                                                    answered Nov 9 '18 at 0:42









                                                                                                    Joi OwenJoi Owen

                                                                                                    1211




                                                                                                    1211























                                                                                                        0














                                                                                                        export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
                                                                                                        apt-get install --reinstall python-openssl






                                                                                                        share|improve this answer
























                                                                                                        • this works fine for me

                                                                                                          – YoungJeXu
                                                                                                          Nov 27 '18 at 3:16
















                                                                                                        0














                                                                                                        export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
                                                                                                        apt-get install --reinstall python-openssl






                                                                                                        share|improve this answer
























                                                                                                        • this works fine for me

                                                                                                          – YoungJeXu
                                                                                                          Nov 27 '18 at 3:16














                                                                                                        0












                                                                                                        0








                                                                                                        0







                                                                                                        export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
                                                                                                        apt-get install --reinstall python-openssl






                                                                                                        share|improve this answer













                                                                                                        export PYTHONPATH="/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/gtk-2.0"
                                                                                                        apt-get install --reinstall python-openssl







                                                                                                        share|improve this answer












                                                                                                        share|improve this answer



                                                                                                        share|improve this answer










                                                                                                        answered Nov 27 '18 at 3:16









                                                                                                        YoungJeXuYoungJeXu

                                                                                                        13




                                                                                                        13













                                                                                                        • this works fine for me

                                                                                                          – YoungJeXu
                                                                                                          Nov 27 '18 at 3:16



















                                                                                                        • this works fine for me

                                                                                                          – YoungJeXu
                                                                                                          Nov 27 '18 at 3:16

















                                                                                                        this works fine for me

                                                                                                        – YoungJeXu
                                                                                                        Nov 27 '18 at 3:16





                                                                                                        this works fine for me

                                                                                                        – YoungJeXu
                                                                                                        Nov 27 '18 at 3:16











                                                                                                        0














                                                                                                        I had the same issue and as pip wasn't working anymore I had to do his job manually:



                                                                                                        wget https://files.pythonhosted.org/packages/40/d0/8efd61531f338a89b4efa48fcf1972d870d2b67a7aea9dcf70783c8464dc/pyOpenSSL-19.0.0.tar.gz
                                                                                                        tar -xzvf pyOpenSSL-19.0.0.tar.gz
                                                                                                        cd pyOpenSSL-19.0.0
                                                                                                        sudo python setup.py install


                                                                                                        After that everything worked as expected.






                                                                                                        share|improve this answer






























                                                                                                          0














                                                                                                          I had the same issue and as pip wasn't working anymore I had to do his job manually:



                                                                                                          wget https://files.pythonhosted.org/packages/40/d0/8efd61531f338a89b4efa48fcf1972d870d2b67a7aea9dcf70783c8464dc/pyOpenSSL-19.0.0.tar.gz
                                                                                                          tar -xzvf pyOpenSSL-19.0.0.tar.gz
                                                                                                          cd pyOpenSSL-19.0.0
                                                                                                          sudo python setup.py install


                                                                                                          After that everything worked as expected.






                                                                                                          share|improve this answer




























                                                                                                            0












                                                                                                            0








                                                                                                            0







                                                                                                            I had the same issue and as pip wasn't working anymore I had to do his job manually:



                                                                                                            wget https://files.pythonhosted.org/packages/40/d0/8efd61531f338a89b4efa48fcf1972d870d2b67a7aea9dcf70783c8464dc/pyOpenSSL-19.0.0.tar.gz
                                                                                                            tar -xzvf pyOpenSSL-19.0.0.tar.gz
                                                                                                            cd pyOpenSSL-19.0.0
                                                                                                            sudo python setup.py install


                                                                                                            After that everything worked as expected.






                                                                                                            share|improve this answer















                                                                                                            I had the same issue and as pip wasn't working anymore I had to do his job manually:



                                                                                                            wget https://files.pythonhosted.org/packages/40/d0/8efd61531f338a89b4efa48fcf1972d870d2b67a7aea9dcf70783c8464dc/pyOpenSSL-19.0.0.tar.gz
                                                                                                            tar -xzvf pyOpenSSL-19.0.0.tar.gz
                                                                                                            cd pyOpenSSL-19.0.0
                                                                                                            sudo python setup.py install


                                                                                                            After that everything worked as expected.







                                                                                                            share|improve this answer














                                                                                                            share|improve this answer



                                                                                                            share|improve this answer








                                                                                                            edited Jan 29 at 12:21









                                                                                                            Philipp Kief

                                                                                                            2,75412232




                                                                                                            2,75412232










                                                                                                            answered Jan 29 at 12:01









                                                                                                            DelaballeDelaballe

                                                                                                            133




                                                                                                            133






























                                                                                                                draft saved

                                                                                                                draft discarded




















































                                                                                                                Thanks for contributing an answer to Stack Overflow!


                                                                                                                • Please be sure to answer the question. Provide details and share your research!

                                                                                                                But avoid



                                                                                                                • Asking for help, clarification, or responding to other answers.

                                                                                                                • Making statements based on opinion; back them up with references or personal experience.


                                                                                                                To learn more, see our tips on writing great answers.




                                                                                                                draft saved


                                                                                                                draft discarded














                                                                                                                StackExchange.ready(
                                                                                                                function () {
                                                                                                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43267157%2fpython-attributeerror-module-object-has-no-attribute-ssl-st-init%23new-answer', 'question_page');
                                                                                                                }
                                                                                                                );

                                                                                                                Post as a guest















                                                                                                                Required, but never shown





















































                                                                                                                Required, but never shown














                                                                                                                Required, but never shown












                                                                                                                Required, but never shown







                                                                                                                Required, but never shown

































                                                                                                                Required, but never shown














                                                                                                                Required, but never shown












                                                                                                                Required, but never shown







                                                                                                                Required, but never shown







                                                                                                                Popular posts from this blog

                                                                                                                Mossoró

                                                                                                                Error while reading .h5 file using the rhdf5 package in R

                                                                                                                Pushsharp Apns notification error: 'InvalidToken'