LoginSignup
2

More than 5 years have passed since last update.

Pythonでopensslに依存したライブラリでエラーが出た時の対策

Last updated at Posted at 2016-05-07

情報

Python

$ python --version

=> Python 2.7.11 :: Continuum Analytics, Inc.

Django

$ python -c "import django; print(django.get_version())"

=> 1.9.6

OSX

$ sw_vers

=>

ProductName:    Mac OS X
ProductVersion: 10.10.5
BuildVersion:   14F1605

トラブルシューティング

pip install mysqlclientしたあとに、python manage.py migrateを実行した以下のエラーが出た

Library not loaded: libssl.1.0.0.dylib

また、

pip install djangorestframeworkしたときも

ImportError: cannot import name HTTPSHandler

どちらも、opensslのライブラリのリンクに問題がある

解決

ということで、再インストールした

$ brew install openssl
$ brew link openssl --force
$ brew uninstall python
$ brew install python --with-brewed-openssl

もう一度実行

$ python manage.py migrate

以下の結果が出ればOK

Operations to perform:
  Apply all migrations: admin, contenttypes, auth, sessions
Running migrations:
  Rendering model states... DONE
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying sessions.0001_initial... OK

djangorestframeworkのほうもう一度

$ pip install djangorestframework

以下の結果が出ればOK

Collecting djangorestframework
  Downloading djangorestframework-3.3.3-py2.py3-none-any.whl (662kB)
    100% |████████████████████████████████| 665kB 542kB/s 
Installing collected packages: djangorestframework
Successfully installed djangorestframework-3.3.3

参考資料

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2