【问题标题】:How to use or install MagickWand on Mac OS X?如何在 Mac OS X 上使用或安装 MagickWand?
【发布时间】:2014-07-17 12:35:08
【问题描述】:

我对 magickwand、python 和 Mac OX X 有疑问。

当我导入它时,我得到了错误:

ImportError: MagickWand shared library not found. You probably had not
installed ImageMagick library. Try to install:   brew install imagemagick

brew install imagemagick Warning: imagemagick-6.8.9-1 already installed

【问题讨论】:

    标签: python macos imagemagick


    【解决方案1】:

    让 Wand 与 imagemagick 7 一起工作:

    brew install imagemagick
    echo 'export MAGICK_HOME=/opt/homebrew/opt/imagemagick/' >> ~/.zshrc
    echo 'export PATH="/opt/homebrew/opt/imagemagick/bin:$PATH"' >> ~/.zshrc
    

    【讨论】:

    • 对于 Apple Silicon (Apple M1) 用户,这是因为 homebrew 目录不同
    【解决方案2】:
    brew uninstall --force imagemagick
    
    brew install imagemagick@6
    
    echo 'export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"' >> ~/.bash_profile
    
    brew link imagemagick@6 --force
    

    【讨论】:

      【解决方案3】:

      根据 Gowtham 和 jrjc 的回答,以下是我如何使用自制软件让 Wand python 包工作:

      brew install imagemagick@6
      
      echo 'export MAGICK_HOME=/usr/local/opt/imagemagick@6/' >> ~/.bash_profile
      

      这里有几点需要注意:

      • 在撰写本文时 wand 还不支持 imagemagick 7,请参阅 https://github.com/dahlia/wand/issues/316。
      • MAGICK_HOME 似乎是设置变量的更好方法 - 正如 jrjr 的回答所提到的,wand docs 中提到了它,如果你真的很好奇,你可以在 library_paths 方法下查看 Wand 如何在 api.py 中查找东西.我无法让 Gowtham 导出 bin 目录的方法起作用。

      【讨论】:

        【解决方案4】:

        所以,实际的问题是:

        如果你的 Python 没有使用 MacPorts 安装,你也必须导出 MAGICK_HOME 路径。因为不是使用 MacPorts 安装的 Python 不会查找 /opt/local,这是 MacPorts 包的默认路径前缀。

        from wand doc

        他们提供的解决方案是:

        $ export MAGICK_HOME=/opt/local

        【讨论】:

        • easy_install 没有这个包。我在这个文件夹中有 imagemagick:/usr/local/Cellar/imagemagick /usr/local/Library/LinkedKegs/imagemagick /usr/local/opt/imagemagick 是否正确?
        • 试试easy_install MagickWand,这是python版本的imagemagick
        • 同样的错误:from wand.image import Image Traceback (most recent call last): File "<stdin>", line 1, in <module> File "build/bdist.macosx-10.9-x86_64/egg/wand/image.py", line 20, in <module> File "build/bdist.macosx-10.9-x86_64/egg/wand/api.py", line 161, in <module> ImportError: MagickWand shared library not found. You probably had not installed ImageMagick library. Try to install: brew install imagemagick
        • 啊,好吧,试试这个:export MAGICK_HOME=/opt/local(在 bash 中)。如果它不起作用我不知道。 (除了尝试用 macport 安装)
        • 最后一次尝试:在 ~/.bash_profile 中写入 export MAGICK_HOME=/opt/local;然后在shell中写:source ~/.bash_profile;然后开始你的 python 会话并做你的事情。如果还是不行,安装 macport 并用它安装 imagemagick。
        猜你喜欢
        • 2010-11-15
        • 2014-11-29
        • 2011-04-10
        • 2012-07-27
        • 2012-03-01
        • 2013-04-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多