Pkg.add("Pkg") issue unknown package Pkg

Hi!
I am trying to use Image Processing (with OpenCV) in Julia. The installation instructions say:

using Pkg
Pkg.add("Images")
Pkg.add("ImageMetadata")
Pkg.add("ImageView")
Pkg.add("TestImages")
Pkg.update()

I am using v0.6.4 Julia version on Ubuntu 16.04. I tried using compiled binaries and even compiled Julia myself using github instructions.

When I try to run, using Pkg, I get the following error:

julia> using Pkg
ERROR: ArgumentError: Module Pkg not found in current path.
Run `Pkg.add("Pkg")` to install the Pkg package.
Stacktrace:
 [1] _require(::Symbol) at ./loading.jl:435
 [2] require(::Symbol) at ./loading.jl:405

When I do, Pkg.add("Pkg"), I get the following error:

julia> Pkg.add("Pkg")
ERROR: unknown package Pkg
macro expansion at ./pkg/entry.jl:53 [inlined]
(::Base.Pkg.Entry.##1#3{String,Base.Pkg.Types.VersionSet})() at ./task.jl:335
Stacktrace:
 [1] sync_end() at ./task.jl:287
 [2] macro expansion at ./task.jl:303 [inlined]
 [3] add(::String, ::Base.Pkg.Types.VersionSet) at ./pkg/entry.jl:51
 [4] (::Base.Pkg.Dir.##4#7{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}})() at ./pkg/dir.jl:36
 [5] cd(::Base.Pkg.Dir.##4#7{Array{Any,1},Base.Pkg.Entry.#add,Tuple{String}}, ::String) at ./file.jl:70
 [6] #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N} where N) at ./pkg/dir.jl:36
 [7] add(::String) at ./pkg/pkg.jl:117

I tried using Jula v0.7 (beta version), and using Pkg worked fine without any error. I was also able to add other packages mentioned before. But, when I do using Images, ImageMetadata, TestImages, ImageView, I again get an error in compilation.

Can someone help me out please? I even tried the same on Ubuntu 18.04 but the same errors.

Thanks
Vishwesh

You have encountered an unstable documentation version. The above will apply to Julia v0.7 and compatible packages. The image processing stack for v0.7 is not quite ready for general use (we are actively working on it). Could you say where you saw this? Maybe there is a “stable” version of the corresponding document which applies to v0.6. Otherwise, you can try simply omitting the using Pkg step and doing Pkg.update() before the other Pkg calls, but there may be other inappropriate things in the unstable documents.

I think the documents at https://juliaimages.github.io are still set up for v0.6.

1 Like

In Julia 0.6 the package manager is not a standalone package, only a submodule of Base. You need using Base.Pkg on Julia 0.6. (However that is not needef since Pkg is exported and you can do Pkg operations without this using step.)

Thank you @Ralph_Smith for the reply. This code was present in Hands-On Computer Vision with Julia.
As you mentioned, I tried 0.7.0-beta version… I was able to carry out the Pkg.add steps. But, when I try using step, I get the following errors:

julia> using Images, ImageMetadata, TestImages, ImageView
[ Info: Precompiling module Images
WARNING: importing deprecated binding Base.fft into Images.
WARNING: importing deprecated binding Base.ifft into Images.
WARNING: could not import Base.linearindexing into Images
WARNING: Method definition (::Type{AxisArrays.CategoricalVector{T, A} where A<:AbstractArray{T, 1} where T})(AbstractArray{T, 1}) where {T} in module AxisArrays at /home/hp/.julia/packages/AxisArrays/uZ7J/src/categoricalvector.jl:43 overwritten at /home/hp/.julia/packages/AxisArrays/uZ7J/src/categoricalvector.jl:47.
WARNING: Method definition (::Type{AxisArrays.CategoricalVector{T, A} where A<:AbstractArray{T, 1} where T})(A<:AbstractArray{T, 1}) where {T, A<:AbstractArray{T, 1}} in module AxisArrays at /home/hp/.julia/packages/AxisArrays/uZ7J/src/categoricalvector.jl:47 overwritten at /home/hp/.julia/packages/AxisArrays/uZ7J/src/categoricalvector.jl:43.
WARNING: Method definition (::Type{AxisArrays.CategoricalVector{T, A} where A<:AbstractArray{T, 1} where T})(AbstractArray{T, 1}) where {T} in module AxisArrays at /home/hp/.julia/packages/AxisArrays/uZ7J/src/categoricalvector.jl:43 overwritten at /home/hp/.julia/packages/AxisArrays/uZ7J/src/categoricalvector.jl:47.
WARNING: importing deprecated binding Base.CartesianRange into ImageFiltering.
WARNING: Base.CartesianRange is deprecated, use CartesianIndices instead.
  likely near /home/hp/.julia/packages/ImageFiltering/cNt7/src/utils.jl:31
WARNING: Base.CartesianRange is deprecated, use CartesianIndices instead.
  likely near /home/hp/.julia/packages/ImageFiltering/cNt7/src/utils.jl:51
ERROR: LoadError: LoadError: TypeError: in apply_type, in Vararg count, expected Int64, got Type{CartesianIndex{0}}
Stacktrace:
 [1] top-level scope at none:0
 [2] include at ./boot.jl:317 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1034
 [4] include at ./sysimg.jl:29 [inlined]
 [5] include(::String) at /home/hp/.julia/packages/ImageFiltering/cNt7/src/ImageFiltering.jl:3
 [6] top-level scope at none:0
 [7] include at ./boot.jl:317 [inlined]
 [8] include_relative(::Module, ::String) at ./loading.jl:1034
 [9] include(::Module, ::String) at ./sysimg.jl:29
 [10] top-level scope at none:0
 [11] eval at ./boot.jl:319 [inlined]
 [12] eval(::Expr) at ./client.jl:394
 [13] top-level scope at ./none:3 [inlined]
 [14] top-level scope at ./<missing>:0
in expression starting at /home/hp/.julia/packages/ImageFiltering/cNt7/src/utils.jl:51
in expression starting at /home/hp/.julia/packages/ImageFiltering/cNt7/src/ImageFiltering.jl:44
ERROR: LoadError: Failed to precompile ImageFiltering to /home/hp/.julia/compiled/v0.7/ImageFiltering/MN5u.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] macro expansion at ./logging.jl:298 [inlined]
 [3] compilecache(::Base.PkgId) at ./loading.jl:1173
 [4] _require(::Base.PkgId) at ./logging.jl:298
 [5] require(::Base.PkgId) at ./loading.jl:838
 [6] require(::Module, ::Symbol) at ./loading.jl:833
 [7] include at ./boot.jl:317 [inlined]
 [8] include_relative(::Module, ::String) at ./loading.jl:1034
 [9] include(::Module, ::String) at ./sysimg.jl:29
 [10] top-level scope at none:0
 [11] eval at ./boot.jl:319 [inlined]
 [12] eval(::Expr) at ./client.jl:394
 [13] top-level scope at ./none:3 [inlined]
 [14] top-level scope at ./<missing>:0
in expression starting at /home/hp/.julia/packages/Images/HB5L/src/Images.jl:49
ERROR: Failed to precompile Images to /home/hp/.julia/compiled/v0.7/Images/H8Vx.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] macro expansion at ./logging.jl:298 [inlined]
 [3] compilecache(::Base.PkgId) at ./loading.jl:1173
 [4] _require(::Base.PkgId) at ./loading.jl:942
 [5] require(::Base.PkgId) at ./loading.jl:838
 [6] require(::Module, ::Symbol) at ./loading.jl:833

The book mentions this:

julia> VERSION
v"0.7.0-DEV.4465"

And the issue is, I can’t find this exact version anywhere. Adding to that, the book was first published in June 2018 and updated in July 2018.

Can you please help me out with this?

Thanks

Thanks @fredrikekre for the reply. I was able to work it out without using the using Pkg step. Hopefully things will work smoothly from now on for me.