I am unable to install the SparseArray package in Julia 1.1.0 . I am getting the following error message. This is a very basic package needed in any application that deals with large data.
julia> import Pkg; Pkg.add(“SparseArray”)
Updating registry at ~/.julia/registries/General
Updating git-repo https://github.com/JuliaRegistries/General.git
ERROR: The following package names could not be resolved:
SparseArray (not found in project, manifest or registry)
Please specify by known name=uuid.
Stacktrace:
[1] pkgerror(::String) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/Types.jl:120
[2] #ensure_resolved#72(::Bool, ::Function, ::Pkg.Types.EnvCache, ::Array{Pkg.Types.PackageSpec,1}) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/Types.jl:1010
[3] #ensure_resolved at ./none:0 [inlined]
[4] #add_or_develop#15(::Symbol, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:49
[5] #add_or_develop at ./none:0 [inlined]
[6] #add_or_develop#14 at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:31 [inlined]
[7] #add_or_develop at ./none:0 [inlined]
[8] #add_or_develop#13 at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:29 [inlined]
[9] #add_or_develop at ./none:0 [inlined]
[10] #add_or_develop#12(::Base.Iterators.Pairs{Symbol,Symbol,Tuple{Symbol},NamedTuple{(:mode,),Tuple{Symbol}}}, ::Function, ::String) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:28
[11] #add_or_develop at ./none:0 [inlined]
[12] #add#20 at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:59 [inlined]
[13] add(::String) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:59
[14] top-level scope at none:0
Thanks again. For new users like me, it is really difficult to track depreciations in new versions. But I guess many features of Julia are still in development.
For the moment, spzeros(n,n) is working fine for me.
FWIW, Julia 1.0 was the first stable version, and allowing changes to the API was implicit in the 0.* versioning. Now in 1.x there should be very few breaking changes.
I highly recommend following @Tamas_Papp’s advice. Upgrading from pre-1.0 to 1.x is so much easier if you use version 0.7. That’s why we made it!
julia> VERSION
v"0.7.0-rc2.0"
julia> speye(10,10)
WARNING: Base.speye is deprecated: it has been moved to the standard library
package `SparseArrays`.
Add `using SparseArrays` to your imports.
in module Main
┌ Warning: `speye(m::Integer, n::Integer)` has been deprecated in favor of `I`,
`sparse`, and `SparseMatrixCSC` constructor methods. For a direct replacement,
consider `sparse(1.0I, m, n)`, `SparseMatrixCSC(1.0I, m, n)`, or
`SparseMatrixCSC{Float64}(I, m, n)`. If `Float64` element type is not necessary,
consider the shorter `sparse(I, m, n)` or `SparseMatrixCSC(I, m, n)` (with default `eltype(I)` of `Bool`).
│ caller = top-level scope at none:0
└ @ Core none:0
10×10 SparseArrays.SparseMatrixCSC{Float64,Int64} with 10 stored entries:
...
Try use julia 0.7 and use speye, it will tell you how to do it because julia 0.7 has deprecation warnings. Julia 0.7 is good when upgrading code. It is better to use julia 0.7 first because it will tell you what the replacement is for upgrading code.
It looks like you already defined I to mean something different in your current Julia session. We’re referencing LinearAlgebra.I. This will do the same (and skirt around a shadowed binding for I):