What to Do When You Can't Import `requests` (_ssl) in Python 3 on a Mac

Python
2015-06-17 20:08 (9 years ago) ytyng
Traceback (most recent call last):
  File "/Applications/Develop/PyCharm.app/helpers/pycharm/django_test_manage.py", line 51, in <module>
    django.setup()
  ...
  File "/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  ...
  File "/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/ssl.py", line 97, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: dlopen(/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload/_ssl.so, 2): Symbol not found: _SSLv2_method
  Referenced from: /usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload/_ssl.so
  Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
 in /usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload/_ssl.so

I started getting this error.

After reinstalling python with brew and recreating the virtualenv, the issue was resolved.

$ brew unlink python3
$ brew install python3

$ rm -r .virtualenvs/myvirtualenv

$ pyvenv-3.4 .virtualenvs/myvirtualenv
$ workon myvirtualenv
$ pip install --upgrade pip
$ pip install -r requirements.txt
...

* After running brew install python, I encountered another issue when starting vim:

    import io as _io
  File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException

Since I encountered this error, I uninstalled python using brew uninstall python.

Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011