LoginSignup
3
5

More than 5 years have passed since last update.

<Julia> 画像関連パッケージ導入時のトラブル

Posted at

Juliaで画像関連パッケージを導入しようとしたところ、インストールやらインポートやらで詰まって苦労したので備忘録として。

導入したJuliaの画像関連パッケージは以下の3つ。
Images: https://github.com/JuliaImages/Images.jl
TestImages: https://github.com/JuliaImages/TestImages.jl
ImageView: https://github.com/JuliaImages/ImageView.jl

環境はMacOS Sierra。Juliaのversionは1.0.3。

Juliaのインストール手順は以前の記事参照。

最終的にうまくいった手順

以下まとめ。

$ brew install gtk+3
$ julia
julia> ]
(v1.0) pkg> add Images
(v1.0) pkg> add TestImages
(v1.0) pkg> add Cairo
(v1.0) pkg> build Cairo
(v1.0) pkg> add ImageView
(v1.0) pkg> add QuartzImageIO
(v1.0) pkg> add ImageMagick

Jupyter notebookで

using ImageView
using Images
using TestImages
img = testimage("mandrill")

#┌ Info: Precompiling QuartzImageIO [dca85d43-d64c-5e67-8c65-017450d5d020]
#└ @ Base loading.jl:1192

ダウンロード.png

環境によってはHomebrewで事前に入れておくべき画像関連パッケージが、他にもあるかもしれない。

ImageViewインストール時のトラブル

ImageViewのインストールがCairoのbuildのところで失敗して強制終了。

Cairoだけ事前にインストールして、buildしておくことでなぜか解決。

ImageViewインポート時のトラブル

using ImageView

エラーメッセージ

[ Info: Precompiling ImageView [86fae568-95e7-573e-a6b2-d8a6b900c9ef]
WARNING: Method definition _bcs1(Any, Any) in module Broadcast at broadcast.jl:439 overwritten in module ImageFiltering at /Users/username/.julia/packages/ImageFiltering/uDyMQ/src/ImageFiltering.jl:24.
ERROR: LoadError: error compiling top-level scope: could not load library "libgtk-3"
dlopen(libgtk-3.dylib, 1): image not found
Stacktrace:
 [1] include at ./boot.jl:317 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1044
 [3] include(::Module, ::String) at ./sysimg.jl:29
 [4] top-level scope at none:2
 [5] eval at ./boot.jl:319 [inlined]
 [6] eval(::Expr) at ./client.jl:393
 [7] top-level scope at ./none:3
in expression starting at /Users/username/.julia/packages/Gtk/ADDrn/src/Gtk.jl:43
ERROR: LoadError: Failed to precompile Gtk [4c0ca9eb-093a-5379-98c5-f87ac0bbbf44] to /Users/username/.julia/compiled/v1.0/Gtk/Vjnq0.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1203
 [3] _require(::Base.PkgId) at ./loading.jl:960
 [4] require(::Base.PkgId) at ./loading.jl:858
 [5] require(::Module, ::Symbol) at ./loading.jl:853
 [6] include at ./boot.jl:317 [inlined]
 [7] include_relative(::Module, ::String) at ./loading.jl:1044
 [8] include(::Module, ::String) at ./sysimg.jl:29
 [9] top-level scope at none:2
 [10] eval at ./boot.jl:319 [inlined]
 [11] eval(::Expr) at ./client.jl:393
 [12] top-level scope at ./none:3
in expression starting at /Users/username/.julia/packages/ImageView/bEIAo/src/ImageView.jl:5
ERROR: Failed to precompile ImageView [86fae568-95e7-573e-a6b2-d8a6b900c9ef] to /Users/username/.julia/compiled/v1.0/ImageView/4mtgY.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1203
 [3] _require(::Base.PkgId) at ./loading.jl:960
 [4] require(::Base.PkgId) at ./loading.jl:858
 [5] require(::Module, ::Symbol) at ./loading.jl:853

メッセージ自体は長いが、could not load library "libgtk-3"という部分が肝。

Homebrewでgtk+3をインストールすることで解決。

テスト画像読み込み時のトラブル

img = testimage("mandrill")

エラーメッセージ。

All errors:
Errors encountered while loading "/Users/username/.julia/packages/TestImages/6bT9D/images/mandrill.tiff".
   ArgumentError("Package QuartzImageIO not found in current path:\n- Run `import Pkg; Pkg.add(\"QuartzImageIO\")` to install the QuartzImageIO package.\n")
   ArgumentError("Package ImageMagick not found in current path:\n- Run `import Pkg; Pkg.add(\"ImageMagick\")` to install the ImageMagick package.\n")
Fatal error:
ArgumentError: Package QuartzImageIO not found in current path:
- Run `import Pkg; Pkg.add("QuartzImageIO")` to install the QuartzImageIO package.


Stacktrace:
 [1] handle_error(::ArgumentError, ::FileIO.File{FileIO.DataFormat{:TIFF}}) at /Users/username/.julia/packages/FileIO/YJO7Z/src/error_handling.jl:80
 [2] handle_exceptions(::Array{Any,1}, ::String) at /Users/username/.julia/packages/FileIO/YJO7Z/src/error_handling.jl:75
 [3] #load#27(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::FileIO.File{FileIO.DataFormat{:TIFF}}) at /Users/username/.julia/packages/FileIO/YJO7Z/src/loadsave.jl:193
 [4] load(::FileIO.File{FileIO.DataFormat{:TIFF}}) at /Users/username/.julia/packages/FileIO/YJO7Z/src/loadsave.jl:172
 [5] #load#13(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::String) at /Users/username/.julia/packages/FileIO/YJO7Z/src/loadsave.jl:118
 [6] load at /Users/username/.julia/packages/FileIO/YJO7Z/src/loadsave.jl:118 [inlined]
 [7] testimage(::String) at /Users/username/.julia/packages/TestImages/6bT9D/src/TestImages.jl:88
 [8] top-level scope at In[4]:1

パッケージが足りないとのこと。

QuartzImageIOImageMagickをインストールして解決。

3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5