libgdiplus在MacOS M1上问题:Unable to load shared library 'libgdiplus'
问题
在mac上的pycharm中执行下面的代码时出现下面的错误
slide.get_thumbnail(
RuntimeError: Proxy error(TypeInitializationException): The type initializer for 'Gdip' threw an exception. ---> DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibgdiplus, 0x0001): tried: 'liblibgdiplus' (no such file), '/System/Volumes/Preboot/Cryptexes/OSliblibgdiplus' (no such file), '/opt/anaconda3/envs/deepdoc-only/bin/.../lib/liblibgdiplus' (no such file), '/usr/lib/liblibgdiplus' (no such file, not in dyld cache), 'liblibgdiplus' (no such file), '/usr/local/lib/liblibgdiplus' (no such file), '/usr/lib/liblibgdiplus' (no such file, not in dyld cache)
解决
步骤1
https://docs.aspose.com/cells/zh/net/how-to-install-libgdiplus-in-macos/
按照提示安装
brew install mono-libgdiplus
在MasOS M1上安装完,安装目录是/opt/homebrew/Cellar/mono-libgdiplus/6.1_2/lib,此时在pycharm中运行仍旧是不起作用。
步骤2
在pycharm中修改run configuration,新增一个环境变量environment variables
DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/Cellar/mono-libgdiplus/6.1_2/lib
之后在PyCharm中run代码的时候就可以正常使用了。