# Confused by behavior when changing ENV\["PYTHONPATH"\] in new module

**URL:** <https://discourse.julialang.org/t/confused-by-behavior-when-changing-env-pythonpath-in-new-module/104408>\
**Category:** General Usage\
**Tags:** question, pycall, module, scope\
**Created:** [September 29, 2023, 6:48pm UTC](https://discourse.julialang.org/t/confused-by-behavior-when-changing-env-pythonpath-in-new-module/104408 "2023-09-29T18:48:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgalenb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgalenb/32/5645_2.png) [@mgalenb](https://discourse.julialang.org/u/mgalenb)\
**Post date:** [September 29, 2023, 6:48pm UTC](https://discourse.julialang.org/t/confused-by-behavior-when-changing-env-pythonpath-in-new-module/104408/1 "2023-09-29T18:48:01Z")

</div>

I am making a module (which has a local python env installed) and I am trying to add a path to ENV[“PYTHONPATH”] and then import a module I am hacking in

```julia
module Test

ENV["PYTHONPATH"]=joinpath(dirname(@ __FILE__ ), "python/testpy")

using PyCall
const t = PyNULL()
function __init__ ()
    copy!(t,pyimport("testpy"))
end

end

```

However, this can’t find my `testpy` module and failed to compile.

If I leave out the ` __init__ ` function and instead do this

```julia
module Test

ENV["PYTHONPATH"]=joinpath(dirname(@ __FILE__ ), "..", "python/testpy")

using PyCall
const t = PyNULL()

include("test.jl")

end

```

where `test.jl" is:

```julia
copy!(t,pyimport("testpy"))

println(t.something(x))

```

this works and prints out `t.something(x)`. however when I open Julia REPL and do `using Test` then `t` is a `PyNULL()`

I am trying to install the python local to this Julia package (I know it makes the package huge, 1 GB to be exact) as I don’t want to use my user’s Conda environment. this breaks other python modules/scripts I am trying to wrap with Julia

essential, I don’t understand why the “PYTHONPATH” isn’t updated when the ` __init__ ` function runs… Suggestions are welcome!
