Djangoで画像を投稿する機能を作成していたのですがうまく動かなかったので、
loggingを確認したところ下記のようなエラーの記載がありました。
Image: failed to import FpxImagePlugin: No module named 'olefile' /usr/local/lib64/python3.6/site-packages/PIL/Image.py:429
パッケージと記載があるのでpipあたりがおかしいのかと思い下記のコマンドを実行しアップグレードしてみようとしました。
python3.6 install --upgrade pip
すると下記のエラーが出ました。
Collecting pip Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl ERROR: Error checking for conflicts. Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3012, in _dep_map return self.__dep_map File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2806, in __getattr__ raise AttributeError(attr) AttributeError: _DistInfoDistribution__dep_map During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3003, in _parsed_pkg_info return self._pkg_info File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2806, in __getattr__ raise AttributeError(attr) AttributeError: _pkg_info During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 517, in _warn_about_conflicts package_set, _dep_info = check_install_conflicts(to_install) File "/usr/local/lib/python3.6/site-packages/pip/_internal/operations/check.py", line 110, in check_install_conflicts package_set, _ = create_package_set_from_installed() File "/usr/local/lib/python3.6/site-packages/pip/_internal/operations/check.py", line 49, in create_package_set_from_installed package_set[name] = PackageDetails(dist.version, dist.requires()) File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2727, in requires dm = self._dep_map File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3014, in _dep_map self.__dep_map = self._compute_dependencies() File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3023, in _compute_dependencies for req in self._parsed_pkg_info.get_all('Requires-Dist') or []: File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3005, in _parsed_pkg_info metadata = self.get_metadata(self.PKG_INFO) File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1419, in get_metadata value = self._get(self._fn(self.egg_info, name)) File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1607, in _get with open(path, 'rb') as stream: FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.6/site-packages/pip-19.2.3.dist-info/METADATA' Installing collected packages: pip Found existing installation: pip 19.2.3 ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/usr/local/lib/python3.6/site-packages/pip-19.2.3.dist-info/RECORD'
上記の文中に下記のような記述があります。
No such file or directory: '/usr/local/lib/python3.6/site-packages/pip-19.2.3.dist-info/RECORD'
ファイルが読み込めていないようだったので念の為に上記のパスを確認してみたところ下記のように表示されてしまいました。
[root@a05020a8e696 django_project]# cd /usr/local/lib/python3.6/site-packages/pip-19.2.3.dist-info/ [root@a05020a8e696 pip-19.2.3.dist-info]# ll ls: cannot access INSTALLER: No such file or directory ls: cannot access LICENSE.txt: No such file or directory ls: cannot access METADATA: No such file or directory ls: cannot access RECORD: No such file or directory ls: cannot access WHEEL: No such file or directory ls: cannot access entry_points.txt: No such file or directory ls: cannot access top_level.txt: No such file or directory total 0 ?????????? ? ? ? ? ? entry_points.txt ?????????? ? ? ? ? ? INSTALLER ?????????? ? ? ? ? ? LICENSE.txt ?????????? ? ? ? ? ? METADATA ?????????? ? ? ? ? ? RECORD ?????????? ? ? ? ? ? top_level.txt ?????????? ? ? ? ? ? WHEEL [root@a05020a8e696 pip-19.2.3.dist-info]#
いつからこうなってしまったのかは不明なのですが『??????』になってしまっているせいでファイルが読み込めていないのではないでしょうか?
どなたかこの現象を解消できた方はいらっしゃいますでしょうか。
ご回答して頂けたら幸いです。
以上よろしくお願いいたします。
下記環境を追記いたします。
[root@a05020a8e696 ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@a05020a8e696 ~]# [root@a05020a8e696 ~]# python3.6 --version Python 3.6.8 [root@a05020a8e696 ~]#
[root@a05020a8e696 ~]# python3.6 Python 3.6.8 (default, Aug 7 2019, 17:28:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import site; site.getsitepackages() ['/usr/local/lib64/python3.6/site-packages', '/usr/local/lib/python3.6/site-packages', '/usr/lib64/python3.6/site-packages', '/usr/lib/python3.6/site-packages'] >>>