Error when "using Symbolics"

I am trying to use the “Symbolics” package but when I have a program that consists only of the line “using Symbolics” I get the error -

WARNING: Method definition isapprox(IntervalSets.AbstractInterval{T} where T, IntervalSets.AbstractInterval{T} where T) in module IntervalSets at /home/brombo/.julia/packages/IntervalSets/viB6k/src/IntervalSets.jl:144 overwritten in module DomainSets at /home/brombo/.julia/packages/DomainSets/aafhp/src/domains/interval.jl:52.
ERROR: Method overwriting is not permitted during Module precompilation. Use __precompile__(false) to opt-out of precompilation.
WARNING: Method definition isapprox(IntervalSets.AbstractInterval{T} where T, IntervalSets.AbstractInterval{T} where T) in module IntervalSets at /home/brombo/.julia/packages/IntervalSets/viB6k/src/IntervalSets.jl:144 overwritten in module DomainSets at /home/brombo/.julia/packages/DomainSets/aafhp/src/domains/interval.jl:52.
ERROR: Method overwriting is not permitted during Module precompilation. Use __precompile__(false) to opt-out of precompilation.

I don’t have a clue as to what to due next. Note I am running on ubuntu 22.04.
I installed julia with “sudo snap install --classic julia” and “Pkg.add(“Symbolics”)” to add the symbolics package. I very ignorant with regard to julia. What should I do next.

In Julia please run versioninfo() and import Pkg; Pkg.status() and report the results here.

Those are just warnings. Did you have an error at all?

ERROR: Method overwriting is not permitted during Module precompilation. Use __precompile__(false) to opt-out of precompilation.

ERROR: Method overwriting is not permitted during Module precompilation. Use __precompile__(false) to opt-out of precompilation.

I don’t know how to use __precompile__(false). Where do you put the statement?

Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 24 × AMD Ryzen 9 5900X 12-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 1 on 24 virtual cores

Status ~/.julia/environments/v1.10/Project.toml
[77e5a97a] AsyPlots v0.2.1
[b964fa9f] LaTeXStrings v1.3.1
[266f59ce] LaTeXTabulars v0.1.3
[d2208f48] LatexPrint v1.1.0
⌅ [23fbe1c1] Latexify v0.15.21
[e9d8d322] Metatheory v2.0.2
[9b87118b] PackageCompiler v2.1.17
⌃ [91a5bcdd] Plots v1.40.0
⌅ [d1185830] SymbolicUtils v0.11.3
⌃ [0c5d862f] Symbolics v0.1.32
Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use status --outdated
WARNING: Method definition isapprox(IntervalSets.AbstractInterval{T} where T, IntervalSets.AbstractInterval{T} where T) in module IntervalSets at /home/brombo/.julia/packages/IntervalSets/viB6k/src/IntervalSets.jl:144 overwritten in module DomainSets at /home/brombo/.julia/packages/DomainSets/aafhp/src/domains/interval.jl:52.
ERROR: Method overwriting is not permitted during Module precompilation. Use __precompile__(false) to opt-out of precompilation.
WARNING: Method definition isapprox(IntervalSets.AbstractInterval{T} where T, IntervalSets.AbstractInterval{T} where T) in module IntervalSets at /home/brombo/.julia/packages/IntervalSets/viB6k/src/IntervalSets.jl:144 overwritten in module DomainSets at /home/brombo/.julia/packages/DomainSets/aafhp/src/domains/interval.jl:52.
ERROR: Method overwriting is not permitted during Module precompilation. Use __precompile__(false) to opt-out of precompilation.

There’s your problem - the current Symbolics release is 5.16, so your version is way out of date. Do ]add Symbolics@5 to find out what’s blocking the update and remove that.

Even better, don’t install all your packages into the default environment but into project-specific environments instead to minimise version conflicts:

https://pkgdocs.julialang.org/v1/environments/

1 Like

I don’t know what you mean by "]add Symbolics@5" that shows up in my email. Where and how do I input``"]add Symbolics@5" ?

In the Julia REPL after just running julia.

You can also do the following.

julia> using Pkg

julia> pkg"add Symbolics@5"

If that does not work, try this.

julia> using Pkg

julia> pkg"activate @symbolics"

julia> pkg"add Symbolics"

julia> using Symbolics

In your script, you would then need to run the following.

using Pkg
Pkg.activate("symbolics", shared = true)
using Symbolics
2 Likes

Thank you, your second suggestion worked.

To explain why this works, your original environment had many packages causing version incompatibilities. You ended up with an old version of Symbolics.jl.

By creating a new environment with just the packages you want, you reduce the potential conflicts.

2 Likes

Please note that my background python and sympy and am trying to learn to use Symbolics.jl to accomplish sympy type tasks. I am trying to define a struct that has @variables as members. Here is my code -

#!/snap/bin/julia

using Pkg
Pkg.activate(“symbolics”, shared = true)
using Symbolics
using SymbolicUtils

@variables W

struct Pdop
vargs
nargs::Int
end

function prt(x::Pdop)
println(x.vargs,’ ',x.nargs)
end

function

pdx = Pdop(W,2)
prt(pdx)

I don’t know what type vargs should be or how to make this legal. Also is there any way to give a variable an alias when printing like a LaTeX string. For example in sympy I can define -

th = symbol(r’\theta_{el}')

Is there an equivalent in Symbolics.jl?

On Discourse please enclose your code with triple backticks

```
like this 
```

so it’s formatted like code and easier to read.

In julia you usually don’t need to put type annotations in function signatures

function prt(x)

is just fine.

To define another name for a variable you can do

julia> @variables θ
1-element Vector{Num}:
 θ

julia> const th = θ
θ

You can make it parametric like this

julia> struct Pdop{T}
           vargs::T
           nargs::Int
       end

Fyi at this point sympy is much more mature and capable than Symbolics.jl, so don’t expect too much.

1 Like

Thank you. Lots of things are becoming much clearer to me. At the moment what I want to use from Symbolic are the capability for algebraic manipulation, differentiation, and simplification.