Repository navigation
pyimport_conda yields PyObject NULL #301
Copy link
Copy link
Open
Description
Hi,
I'm hitting a bug I'm having some trouble replicating, hope you might be able to steer me in the right direction.
At a very high level, the problem happens when I
- Import
sympy.statsin the standard way within my package using Soss(my package) externally- Make a call involving
stats
Result:
julia> Soss.stats
PyObject NULLIn some cases, this triggers a segfault.
For context, I've tried this in both Julia 1.2 and 1.3.
Also, the following works with no trouble:
# in a file
module M
import PyCall
import SymPy
using SymPy: Sym, sympy, symbols
export SymPy, stats, symbols
stats = PyCall.pyimport_conda("sympy.stats", "sympy")
SymPy.import_from(stats)
import Distributions.Normal
export Normal
Normal(μ::Sym, σ::Sym) = stats.Normal(:Normal, μ,σ) |> SymPy.density
Normal(μ,σ) = Normal(promote(μ,σ)...)
end
using Distributions
using .M
stats.Normal(:Normal, symbols(:μ),1) |> SymPy.density
Normal(symbols(:μ),1)
# in the REPL
julia> stats.Normal(:Normal, symbols(:μ),1) |> SymPy.density
NormalDistribution(μ, 1)
julia> Normal(symbols(:μ),1)
NormalDistribution(μ, 1)The code in symbolic.jl takes this same approach. But when I try from a fresh environment, ...
(Soss#dev) pkg> add Soss#dev
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Updating git-repo `https://github.com/cscherrer/Soss.jl.git`
Resolving package versions...
Updating `~/Soss#dev/Project.toml`
[8ce77f84] + Soss v0.6.0 #dev (https://github.com/cscherrer/Soss.jl.git)
Updating `~/Soss#dev/Manifest.toml`
... (other dependencies)
[8f4d0f93] + Conda v1.3.0
[24249f21] + SymPy v1.0.7
julia> using Soss
[ Info: Recompiling stale cache file /home/chad/.julia/compiled/v1.2/Soss/vXX0U.ji for Soss [8ce77f84-9b61-11e8-39ff-d17a774bf41c]
# *LOTS* OF THESE
WARNING: eval into closed module SymPy:
Expr(:block, #= Symbol("/home/chad/.julia/packages/SymPy/1Cwgd/src/utils.jl"):252 =#, Expr(:call, :P, Expr(:parameters, Expr(:..., :kwargs)), Expr(:::, :ex, :SymbolicObject), Expr(:..., :args)) = Expr(:block, #= Symbol("/home/chad/.julia/packages/SymPy/1Cwgd/src/utils.jl"):252 =#, Expr(:call, Expr(:call, :getproperty, PyCall.PyObject(o=0x00007f6c2c085778), "P"), Expr(:parameters, Expr(:..., :kwargs)), :ex, Expr(:..., :args))))
** incremental compilation may be fatally broken for this module **
julia> Soss.stats
PyObject NULLAny ideas?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
jverzani commentedon Oct 15, 2019
cscherrer commentedon Oct 15, 2019
Thanks, but I think I'm missing a lot of context here. I'm guessing by
__init__you mean the class initialization method from Python. I've used this from Python, but never from Julia. It's not clear to me how the pieces connect. Do I need a line line one of the ones you have inimportexport.jl? Or do I need to build something that writes code like this? I looked for a macro that writes this code but don't see anything. Is it a build script somewhere?