Django无法运行,因为GDAL正在加载错误的libtiff版本

qhhrdooz  于 2023-10-21  发布在  Go
关注(0)|答案(1)|浏览(228)

我无法在MacOS Ventura上运行Django。查看错误,我认为GDAL无法加载libtiff库。
我做了一些调查,我有libtiff安装。

% otool -L /opt/homebrew/lib/libgdal.dylib | grep libtiff
    /opt/homebrew/opt/libtiff/lib/libtiff.6.dylib (compatibility version 7.0.0, current version 7.1.0)

如果查看错误,我认为它试图加载libtiff.5.dylib,但我有libtiff.6.dylib。如何让GDAL加载已安装的libtiff?

% python manage.py runserver 
Watching for file changes with StatReloader
2023-10-01 17:14:00,801 INFO Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 980, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Cellar/[email protected]/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 917, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
    raise _exception[1]
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/core/management/__init__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/utils/autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/opt/homebrew/Cellar/[email protected]/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/mapwidgets/__init__.py", line 4, in <module>
    from .widgets import GooglePointFieldWidget, GooglePointFieldInlineWidget, \
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/mapwidgets/widgets.py", line 5, in <module>
    from django.contrib.gis.forms import BaseGeometryWidget
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module>
    from .fields import (  # NOQA
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module>
    from django.contrib.gis.gdal import GDALException
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module>
    from django.contrib.gis.gdal.datasource import DataSource
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/contrib/gis/gdal/datasource.py", line 39, in <module>
    from django.contrib.gis.gdal.driver import Driver
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
    from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
    from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
  File "/Users/myproj/Documents/project/projectdotcom/env_m1/lib/python3.9/site-packages/django/contrib/gis/gdal/libgdal.py", line 47, in <module>
    lgdal = CDLL(lib_path)
  File "/opt/homebrew/Cellar/[email protected]/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/opt/homebrew/lib/libgdal.dylib, 0x0006): Library not loaded: /opt/homebrew/opt/libtiff/lib/libtiff.5.dylib
  Referenced from: <3FEB9C56-E432-36C6-A940-FC254CC92FAB> /opt/homebrew/Cellar/libgeotiff/1.7.1_1/lib/libgeotiff.5.dylib
  Reason: tried: '/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib' (no such file), '/opt/homebrew/opt/libtiff/lib/libtiff.5.dylib' (no such file), '/usr/local/lib/libtiff.5.dylib' (no such file), '/usr/lib/libtiff.5.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/libtiff/4.6.0/lib/libtiff.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/libtiff/4.6.0/lib/libtiff.5.dylib' (no such file), '/opt/homebrew/Cellar/libtiff/4.6.0/lib/libtiff.5.dylib' (no such file), '/usr/local/lib/libtiff.5.dylib' (no such file), '/usr/lib/libtiff.5.dylib' (no such file, not in dyld cache)
jei2mxaa

jei2mxaa1#

我也遇到了同样的问题,我遵循的解决方案来自这个:upgraded libtiff is now causing error while starting django server
基本上,你需要完全卸载Homebrew:
/bin/bash -c“$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)”
重新安装Homebrew:
/bin/bash -c“$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”
然后,brew安装所有相关的软件包,我使用的是当前的GDAL3.7,它恢复到以前的正常工作

相关问题