# Using SymPy.jl inside a module

**URL:** <https://discourse.julialang.org/t/using-sympy-jl-inside-a-module/44191>\
**Category:** New to Julia\
**Created:** [August 3, 2020, 2:20pm UTC](https://discourse.julialang.org/t/using-sympy-jl-inside-a-module/44191 "2020-08-03T14:20:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [August 3, 2020, 2:20pm UTC](https://discourse.julialang.org/t/using-sympy-jl-inside-a-module/44191/1 "2020-08-03T14:20:33Z")

</div>

I got the `ERROR: ArgumentError: ref of NULL PyObject` when I call a function defined inside a module that is `using SymPy`.

seems like the situation is rather similar to [this](https://github.com/JuliaPy/PyCall.jl#using-pycall-from-julia-modules). Unfortunately I have difficulties to transform the solution into the one for `SymPy.jl`.

could anyone help? thanks.

---

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [August 4, 2020, 2:47am UTC](https://discourse.julialang.org/t/using-sympy-jl-inside-a-module/44191/2 "2020-08-04T02:47:33Z")

</div>

after trial-and-errors, putting the following inside a module works:

```julia
import SymPy

### instead of:
# const sympy = SymPy.sympy    

### use the following:
import PyCall
const sympy = PyCall.PyNULL()
function __init__ ()
    copy!(sympy, PyCall.pyimport_conda("sympy", "sympy"))
end

```
