SSL module in Python is not available (on OSX)

后端 未结 7 1716
时光说笑
时光说笑 2020-12-08 19:16

I\'m having trouble running pip install in a virtualenv on OSX 10.13. I already have run brew install openssl and the path /usr/local/include

相关标签:
7条回答
  • 2020-12-08 19:51

    I also had this error and I fixed it with brew update && brew upgrade

    0 讨论(0)
  • 2020-12-08 19:53

    Mac OSX Catalina (and same issue on OSX Mojave) Pyenv

    For anyone searching this topic, I had the same presenting problem, but had Python installed via both Homebrew and Pyenv!! It would have been better (IMO) to just use Pyenv to easily manage versions. As mentioned by @ivan_pozdeev in their answer, but here's some detail you might want.

    If your situation is similar, none of the above solutions would be quite enough to set things right. Partially I was helped by a Pyenv related answer here: https://stackoverflow.com/a/51797298/3084820 I also happened to have pyenv-virtualenv installed, so mentioning that as well, as it's common to use these two together.

    I finally took the following steps to resolve the issue:

    brew uninstall python
    rm -rf $(pyenv root)
    brew uninstall pyenv-virtualenv   # you may not have this installed, but...
    brew uninstall pyenv
    

    Now, for a clean installation manageable with Pyenv:

    brew install pyenv
    pyenv install 3.6.10  (or whatever version you want)
    

    This gave me a clean, working install of Python 3.6.10, and if I wanted or needed to, I could install a different version and switch between with Pyenv.

    0 讨论(0)
  • 2020-12-08 19:53

    I had a similar problem with Catalina and could not get homebrew reinstall to work. I tried several thing.

    brew reinstall openssl
    brew reinstall pyenv
    brew reinstall pyenv-virtualenv
    

    Ultimately the only thing that worked for me was to completely uninstall both as well as the underlying python installations and then reinstall everything.

    brew uninstall pyenv pyenv-virtualenv
    brew install pyenv pyenv-virtualenv
    pyenv uninstall 3.x.x
    pyenv install 3.x.x
    pip install -r requirements.txt
    
    0 讨论(0)
  • 2020-12-08 19:56

    This problem might also be, because your python distribution was compiled using the wrong version of openssl.

    Support for OpenSSL 1.1.x, was only added in Python 2.7.13, 3.5.3 and 3.6.0 (see https://github.com/pyenv/pyenv/issues/950#issuecomment-562366902)

    So if you are trying to install an older version of Python you must first uninstall the new version of openssl with brew and only then you can install an older version of Python with pyenv

    brew uninstall --ignore-dependencies openssl@1.1
    pyenv uninstall 3.5.2  # deinstall old versions compiled with the wrong version of openssl
    pyenv install 3.5.2
    

    On the other side, if you are trying to install newer version of Python make sure you have installed the latest version of openssl available, before you install them with pyenv:

    brew upgrade openssl
    pyenv uninstall 3.7.4 # deinstall old versions compiled with the wrong version of openssl
    pyenv install 3.7.4
    
    0 讨论(0)
  • 2020-12-08 19:57

    I had the same error and it was because I was using python 3.6.5 in my pyenv environment. The below treatment worked for me.

    pyenv install 3.7.3
    pyenv global 3.7.3
    
    0 讨论(0)
  • 2020-12-08 19:58

    My fix is to reinstall pyenv and python

     brew uninstall pyenv pyenv-virtualenv
     brew install pyenv pyenv-virtualenv
     pyenv uninstall 3.6.5
     pyenv install 3.6.5
    
    0 讨论(0)
提交回复
热议问题