ERROR Installing Pkg.add("IJulia"): no active project - julia

I want to install Julia in my jupyter notebook. I am getting this. I am not able to find what means the reference to 'no active Project'. Any help will be very welcomed. Thanks
julia> using Pkg
julia> Pkg.add("IJulia")
ERROR: no active project
Stacktrace:
[1] pkgerror(msg::String)
# Pkg.Types C:\Users\madel\Julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\Types.jl:68
[2] find_project_file(env::Nothing)
# Pkg.Types C:\Users\madel\Julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\Types.jl:200
[3] Pkg.Types.EnvCache(env::Nothing) (repeats 2 times)
# Pkg.Types C:\Users\madel\Julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\Types.jl:319
[4] Pkg.Types.Context()
# Pkg.Types .\util.jl:478
[5] add(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
# Pkg.API C:\Users\madel\Julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\API.jl:145
[6] add(pkgs::Vector{Pkg.Types.PackageSpec})
# Pkg.API C:\Users\madel\Julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\API.jl:144
[7] #add#27
# C:\Users\madel\Julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\API.jl:142 [inlined]
[8] add
# C:\Users\madel\Julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\API.jl:142 [inlined]
[9] #add#26
# C:\Users\madel\Julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\API.jl:141 [inlined]
[10] add(pkg::String)
# Pkg.API C:\Users\madel\Julia-1.7.2\share\julia\stdlib\v1.7\Pkg\src\API.jl:141
[11] top-level scope
# REPL[36]:1
julia>

I tried to add a new environment user path as JULIA_HOME to the following route:
C:\Users\madel\Julia-1.7.2\bin and works now. It seems like I was not pointing the right path.

Related

Julia fails to precompile packages Plots

After I excute Pkg.precompile(), the REPL return the information like following:
julia> using Pkg
julia> Pkg.precompile()
Precompiling project...
✗ GR
✗ Plots
0 dependencies successfully precompiled in 40 seconds (130 already precompiled)
ERROR: The following 1 direct dependency failed to precompile:
Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80]
Failed to precompile Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] to C:\Users\Administrator\.julia\compiled\v1.6\Plots\jl_DB20.tmp.
ERROR: LoadError: ArgumentError: not a path: \`C:\Users\Administrator\.julia\packages\GR\xhzFJ\deps\deps.jl\`
ERROR: LoadError: ArgumentError: not a path: `C:\Users\Administrator\.julia\packages\GR\xhzFJ\deps\deps.jl`
Stacktrace:
[1] RelocatableFolders.Path(mod::Module, dir::String, path::String)
# RelocatableFolders C:\Users\Administrator\.julia\packages\RelocatableFolders\PYUl8\src\RelocatableFolders.jl:51
[2] top-level scope
# C:\Users\Administrator\.julia\packages\GR\xhzFJ\src\GR.jl:36
[3] include
# .\Base.jl:384 [inlined]
[4] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
# Base .\loading.jl:1235
[5] top-level scope
# none:1
[6] eval
# .\boot.jl:360 [inlined]
[7] eval(x::Expr)
# Base.MainInclude .\client.jl:446
[8] top-level scope
# none:1
in expression starting at C:\Users\Administrator\.julia\packages\GR\xhzFJ\src\GR.jl:2
ERROR: LoadError: LoadError: Failed to precompile GR [28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71] to C:\Users\Administrator\.julia\compiled\v1.6\GR\jl_B11E.tmp.
Stacktrace:
[1] error(s::String)
# Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
# Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
# Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
# Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
# Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
# Base .\loading.jl:923
[7] include(mod::Module, _path::String)
# Base .\Base.jl:384
[8] include(x::String)
# Plots C:\Users\Administrator\.julia\packages\Plots\E2187\src\Plots.jl:1
[9] top-level scope
# C:\Users\Administrator\.julia\packages\Plots\E2187\src\Plots.jl:227
[10] include
# .\Base.jl:384 [inlined]
[11] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
# Base .\loading.jl:1235
[12] top-level scope
# none:1
[13] eval
# .\boot.jl:360 [inlined]
[14] eval(x::Expr)
# Base.MainInclude .\client.jl:446
[15] top-level scope
# none:1
in expression starting at C:\Users\Administrator\.julia\packages\Plots\E2187\src\backends\gr.jl:6
in expression starting at C:\Users\Administrator\.julia\packages\Plots\E2187\src\Plots.jl:1
Stacktrace:
[1] pkgerror(msg::String)
# Pkg.Types C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Types.jl:55
[2] precompile(ctx::Pkg.Types.Context; internal_call::Bool, strict::Bool, warn_loaded::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
# Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:1265
[3] precompile
# C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:921 [inlined]
[4] #precompile#196
# C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:919 [inlined]
[5] precompile()
# Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:919
[6] top-level scope
# REPL[2]:1
Please help me!
More details:
Microsoft Windows [10.0.17763.2803]
Julia Version 1.6.6 (2022-03-28). Julia is installed by the installer downloaded from https://julialang.org/downloads/
I am a postgraduate majoring in physics. I am interested in computing and programming. From my classmates the julia lang is a programming language facing futrue because of its advanced programming philosophy. However, what I did not expect is that I meet the problem I can not resolve so soon. (This paragraph is for the prompt "Most is code, please add more details")
I do not even know what have happened till now. However I find the solution for my question and I have succeed in resolving it. Having excute Pkg.add("Plots"), just excute the following codes:
using Pkg
Pkg.add("GR")
Pkg.build("GR")
Pkg.precompile()
The answer is from here

I am encountering an error on Julia while trying to install and use Distributions module

I am encountering an error on Julia while trying to install and use Distributions module. I am not facing any errors while installing the module but it displays this error when I try to use the Distributions module. I have no idea what this PDMats or Manifest files are. I'd love to have some advice. Thanks!
This is the entire error:
julia> using Distributions
│ Package Distributions not found, but a package named Distributions is available from a registry.
│ Install package?
│ (#v1.7) pkg> add Distributions
└ (y/n) [y]: y
Updating registry at `C:\Users\rajaissacsamuel.k\.julia\registries\General.toml`
Resolving package versions...
Updating `C:\Users\rajaissacsamuel.k\.julia\environments\v1.7\Project.toml`
[31c24e10] + Distributions v0.21.12
No Changes to `C:\Users\rajaissacsamuel.k\.julia\environments\v1.7\Manifest.toml`
[ Info: Precompiling Distributions [31c24e10-a181-5473-b8eb-7969acd0382f]
ERROR: LoadError: ArgumentError: Package PDMats does not have IterativeEigensolvers in its dependencies:
- If you have PDMats checked out for development and have
added IterativeEigensolvers as a dependency but haven't updated your primary
environment's manifest file, try `Pkg.resolve()`.
- Otherwise you may need to report an issue with PDMats
Stacktrace:
[1] require(into::Module, mod::Symbol)
# Base .\loading.jl:980
[2] include
# .\Base.jl:418 [inlined]
[3] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
# Base .\loading.jl:1318
[4] top-level scope
# none:1
[5] eval
# .\boot.jl:373 [inlined]
[6] eval(x::Expr)
# Base.MainInclude .\client.jl:453
[7] top-level scope
# none:1
in expression starting at C:\Users\rajaissacsamuel.k\.julia\packages\PDMats\jTYWO\src\PDMats.jl:3
ERROR: LoadError: Failed to precompile PDMats [90014a1f-27ba-587c-ab20-58faa44d9150] to C:\Users\rajaissacsamuel.k\.julia\compiled\v1.7\PDMats\jl_565F.tmp.
Stacktrace:
[1] error(s::String)
# Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
# Base .\loading.jl:1466
[3] compilecache(pkg::Base.PkgId, path::String)
# Base .\loading.jl:1410
[4] _require(pkg::Base.PkgId)
# Base .\loading.jl:1120
[5] require(uuidkey::Base.PkgId)
# Base .\loading.jl:1013
[6] require(into::Module, mod::Symbol)
# Base .\loading.jl:997
[7] include
# .\Base.jl:418 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
# Base .\loading.jl:1318
[9] top-level scope
# none:1
[10] eval
# .\boot.jl:373 [inlined]
[11] eval(x::Expr)
# Base.MainInclude .\client.jl:453
[12] top-level scope
# none:1
in expression starting at C:\Users\rajaissacsamuel.k\.julia\packages\Distributions\KjaXI\src\Distributions.jl:1
ERROR: Failed to precompile Distributions [31c24e10-a181-5473-b8eb-7969acd0382f] to C:\Users\rajaissacsamuel.k\.julia\compiled\v1.7\Distributions\jl_52F6.tmp.
Stacktrace:
[1] error(s::String)
# Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
# Base .\loading.jl:1466
[3] compilecache(pkg::Base.PkgId, path::String)
# Base .\loading.jl:1410
[4] _require(pkg::Base.PkgId)
# Base .\loading.jl:1120
[5] require(uuidkey::Base.PkgId)
# Base .\loading.jl:1013
[6] require(into::Module, mod::Symbol)
# Base .\loading.jl:997
[7] eval
# .\boot.jl:373 [inlined]
[8] eval
# .\Base.jl:68 [inlined]
[9] repleval(m::Module, code::Expr, #unused#::String)
# VSCodeServer c:\Users\rajaissacsamuel.k\.vscode\extensions\julialang.language-julia-1.6.17\scripts\packages\VSCodeServer\src\repl.jl:157
[10] (::VSCodeServer.var"#78#80"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
# VSCodeServer c:\Users\rajaissacsamuel.k\.vscode\extensions\julialang.language-julia-1.6.17\scripts\packages\VSCodeServer\src\repl.jl:123
[11] with_logstate(f::Function, logstate::Any)
# Base.CoreLogging .\logging.jl:511
[12] with_logger
# .\logging.jl:623 [inlined]
[13] (::VSCodeServer.var"#77#79"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
# VSCodeServer c:\Users\rajaissacsamuel.k\.vscode\extensions\julialang.language-julia-1.6.17\scripts\packages\VSCodeServer\src\repl.jl:124
[14] #invokelatest#2
# .\essentials.jl:716 [inlined]
[15] invokelatest(::Any)
# Base .\essentials.jl:714
[16] macro expansion
# c:\Users\rajaissacsamuel.k\.vscode\extensions\julialang.language-julia-1.6.17\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
[17] (::VSCodeServer.var"#60#61")()
# VSCodeServer .\task.jl:423
try Pkg.resolve() or Pkg.update(), if that fails try resetting the Julia registry

Open HDF5 files in Julia

I have Julia 1.7.2 and HDF v"0.16.2" on a Windows 10 machine.
I ran into an issue opening an HDF5 file:
using HDF5
raw_hdf_data = h5open("Data_2021-03-17_11-21-19.h5", "r")
obj = raw_hdf_data["Group"]["Data_1"]
HDF5.read(obj)
but got an error:
HDF5.API.H5Error: Error reading dataset /Flatfield/Data_1
libhdf5 Stacktrace:
[1] H5PL__find_plugin_in_path: Plugin for dynamically
loaded library/Can't open directory or file
can't open directory
⋮
[11] H5Dread: Dataset/Read failed
can't read data
Stacktrace:
[1] macro expansion
# C:\Users\jhsu.julia\packages\HDF5\auFb7\src\api\error.jl:18 [inlined]
[2] h5d_read(dataset_id::HDF5.Dataset,
mem_type_id::HDF5.Datatype, mem_space_id::HDF5.Dataspace,
file_space_id::HDF5.Dataspace,
xfer_plist_id::HDF5.DatasetTransferProperties, buf::Matrix{Int64})
# HDF5.API C:\Users\jhsu.julia\packages\HDF5\auFb7\src\api\functions.jl:508
[3] generic_read(::HDF5.Dataset, ::HDF5.Datatype, ::Type{Int64})
# HDF5 C:\Users\jhsu.julia\packages\HDF5\auFb7\src\HDF5.jl:978
[4] read(obj::HDF5.Dataset)
# HDF5 C:\Users\jhsu.julia\packages\HDF5\auFb7\src\HDF5.jl:878
[5] (::var"#66#67")(fid::HDF5.File)
# Main .\In[68]:3
[6] h5open(::var"#66#67", ::String, ::Vararg{String, N} where N; swmr::Bool,
pv::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(),
Tuple{}}})
# HDF5 C:\Users\jhsu.julia\packages\HDF5\auFb7\src\HDF5.jl:287
[7] h5open(::Function, ::String, ::String)
# HDF5 C:\Users\jhsu.julia\packages\HDF5\auFb7\src\HDF5.jl:285
[8] top-level scope
# In[68]:1
[9] eval
# .\boot.jl:360 [inlined]
[10] include_string(mapexpr::typeof(REPL.softscope), mod::Module,
code::String, filename::String)
# Base .\loading.jl:1116
Thanks very much!
I had the same issue when I updated my HDF5 library.
Probably the file is compressed and one of the following plugins are necessary. Try:
] add H5Zblosc, H5Zbzip2, H5Zlz4, H5Zzstd
using HDF5, H5Zblosc, H5Zbzip2, H5Zlz4, H5Zzstd
raw_hdf_data = h5open("Data_2021-03-17_11-21-19.h5", "r")
...
Now it should open the file.

Julia Plots animate `gif()` hangs indefinitely

I am experiencing slightly strange behaviour from a visualisation routine I have written using Plots.jl. The module I have written uses code of the following form (with some irrelevant details removed). It is intended to produce a 2D animation of the results of a 2D partial differential equation.
anim = #animate for (i,u) in enumerate(sol.u)
heatmap(u)
end
gif(anim,"output/anim_u.gif",fps=5)
If I run my program with this code at the end, the program hangs indefinitely after opening a "gksqt" application in the dock. Killing the program produces the following stacktrace.
Stacktrace:
[1] poptask(W::Base.InvasiveLinkedListSynchronized{Task})
# Base ./task.jl:760
[2] wait
# ./task.jl:768 [inlined]
[3] wait(c::Base.GenericCondition{Base.Threads.SpinLock})
# Base ./condition.jl:106
[4] wait(x::Base.Process)
# Base ./process.jl:621
[5] success
# ./process.jl:483 [inlined]
[6] run(::Cmd; wait::Bool)
# Base ./process.jl:440
[7] run
# ./process.jl:438 [inlined]
[8] (::FFMPEG.var"#4#6"{Cmd})(command_path::String)
# FFMPEG ~/.julia/packages/FFMPEG/OUpap/src/FFMPEG.jl:112
[9] (::JLLWrappers.var"#2#3"{FFMPEG.var"#4#6"{Cmd}, String})()
# JLLWrappers ~/.julia/packages/JLLWrappers/bkwIo/src/runtime.jl:49
[10] withenv(::JLLWrappers.var"#2#3"{FFMPEG.var"#4#6"{Cmd}, String}, ::Pair{String, String}, ::Vararg{Pair{String, String}, N} where N)
# Base ./env.jl:161
[11] withenv_executable_wrapper(f::Function, executable_path::String, PATH::String, LIBPATH::String, adjust_PATH::Bool, adjust_LIBPATH::Bool)
# JLLWrappers ~/.julia/packages/JLLWrappers/bkwIo/src/runtime.jl:48
[12] #invokelatest#2
# ./essentials.jl:708 [inlined]
[13] invokelatest
# ./essentials.jl:706 [inlined]
[14] #ffmpeg#7
# ~/.julia/packages/JLLWrappers/bkwIo/src/products/executable_generators.jl:7 [inlined]
[15] ffmpeg
# ~/.julia/packages/JLLWrappers/bkwIo/src/products/executable_generators.jl:7 [inlined]
[16] #exe#2
# ~/.julia/packages/FFMPEG/OUpap/src/FFMPEG.jl:111 [inlined]
[17] ffmpeg_exe
# ~/.julia/packages/FFMPEG/OUpap/src/FFMPEG.jl:123 [inlined]
[18] buildanimation(anim::Plots.Animation, fn::String, is_animated_gif::Bool; fps::Int64, loop::Int64, variable_palette::Bool, verbose::Bool, show_msg::Bool)
# Plots ~/.julia/packages/Plots/S2aH5/src/animation.jl:96
I am completely baffled by this behaviour - if anyone has any suggestions it would be greatly appreciated.
Running on MacOS 11.2.3 with Julia 1.6.2.

julia: UndefRefError: access to undefined reference

I'm trying to create a POMDP model and solve it. But during the solving process, I get this error:
Got exception outside of a #test
UndefRefError: access to undefined reference
Stacktrace:
[1] getindex
# ./array.jl:801 [inlined]
[2] iterate
# ./array.jl:777 [inlined]
[3] iterate
# ./iterators.jl:159 [inlined]
[4] write(io::IOStream, pomdp::AccPOMDP)
# POMDPFiles ~/.julia/packages/POMDPFiles/vOfxh/src/write.jl:64
[5] #3
# ~/.julia/packages/POMDPSolve/LzAMF/src/solver.jl:175 [inlined]
[6] open(::POMDPSolve.var"#3#4"{AccPOMDP}, ::String, ::Vararg{String, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
# Base ./io.jl:330
[7] open
# ./io.jl:328 [inlined]
[8] solve(solver::POMDPSolveSolver, pomdp::AccPOMDP)
# POMDPSolve ~/.julia/packages/POMDPSolve/LzAMF/src/solver.jl:174
[9] macro expansion
# ~/jl/acc/acc_dev.jl:556 [inlined]
[10] macro expansion
# /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
[11] top-level scope
# ~/jl/acc/acc_dev.jl:546
[12] include(mod::Module, _path::String)
# Base ./Base.jl:386
[13] exec_options(opts::Base.JLOptions)
# Base ./client.jl:285
[14] _start()
# Base ./client.jl:485
I'm not so familiar with the Julia Stacktrace, so could you please help me fix this problem?
Caused by stateindex(...) and states(...) wrong implementation in my POMDP model. But after I fix this ans start to solve the problem, the solving just kept run and finally failed. Just want to complain, Julia POMDP is really hard to use in reality...

Resources