VPS の
前提
移行前と
OS Version
- 移行前
cat /etc/redhat-release CentOS release 6.9 (Final)
- 移行後
cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core)
- 移行前
Python の
Version 移行前
python2.7 -V Python 2.7.8
移行後
python3.6 -V Python 3.6.4
発生した Python エラー
ModuleNotFoundError: No module named ‘memcache’
原因
memcache モジュールがない。
python-memcached
をインストールしていなかった。 対処法
python-memcached
をインストールした。 python3.6 -m pip install python-memcached
参考
python - Importerror: No module named memcache (Django project) - Stack Overflow
No module named ‘StringIO’
原因
Python 2 と、Python 3 で、 StringIO
のパッケージが 変更されており、 Python 3 では import に 失敗していた。 対処法
import 箇所の実装を 以下のように 修正した。 try: from StringIO import StringIO except ImportError: from io import StringIO
django.template.exceptions.TemplateSyntaxError: ‘compress’ is not a registered tag library
原因
django-compressor
をインストールしていなかった。 対処法
django-compressor
をインストールした。 python3.6 -m pip install django-compressor
Penthouse 実行時に error while loading shared libraries: libfontconfig.so.1 が 発生
これは、
原因
fontconfig-devel
という ライブラリが インストールされていなかった。 対処法
fontconfig-devel
をインストール。 yum -y install fontconfig-devel
TypeError: Unicode-objects must be encoded before hashing
原因
hashlib という ライブラリで エラー、 Python 2 では 動作するが、 Python 3 では hash 化する 前に、 エンコーディングを する 必要が ある。 対処法
対象箇所の実装を 以下のように 修正した。 import six h = hashlib.sha1() if six.PY2: h.update(critical_css_fragment) else: h.update(critical_css_fragment.encode("utf-8"))
cssmin.py で、 TypeError: a bytes-like object is required, not ‘str’ が 発生
zacharyvoase/cssmin: NO LONGER MAINTAINED. A Python port of the YUI CSS compression algorithm. で
原因
cssmin.py のPython 3 の 互換性の 問題かと 思いましたが、 本体ではなく、 使用している 側で decode 指定が ないのが 原因でした。 対処法
cssmin.py の使用箇所を 修正し、 Python 3 の 場合、 decode 処理を 行うようにしました。 import six if six.PY2: critical_css = cssmin(critical_css) else: critical_css = cssmin(critical_css.decode('utf-8'))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused
原因
MongoDB をインストールしていない。 対処法
MongoDB をインストールした。
ModuleNotFoundError: No module named ‘HTMLParser’
原因
Python2 > Python3 でHTMLParser の パッケージが 変更に なった。 対処法
HTMLParser のimport 記述を 以下のように 修正した。 try: import HTMLParser except ImportError: from html.parser import HTMLParser
以上です。
コメント