# Loading a precompiled module does not respect the module import order

**URL:** <https://discourse.julialang.org/t/loading-a-precompiled-module-does-not-respect-the-module-import-order/83560>\
**Category:** General Usage\
**Tags:** precompilation\
**Created:** [June 30, 2022, 9:34am UTC](https://discourse.julialang.org/t/loading-a-precompiled-module-does-not-respect-the-module-import-order/83560 "2022-06-30T09:34:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thautwarm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thautwarm/32/37760_2.png) [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Post date:** [June 30, 2022, 9:34am UTC](https://discourse.julialang.org/t/loading-a-precompiled-module-does-not-respect-the-module-import-order/83560/1 "2022-06-30T09:34:52Z")

</div>

I’ve just made a package [JuliaPythonAdaptor.jl](https://github.com/thautwarm/JuliaPythonAdaptor.jl) that helps automatically setting up environment variables required by PythonCall.jl.

Things works pretty fine if I use these two packages in REPL:

```julia
# 'JuliaPythonAdaptor. __init__' modifies 'ENV'.
julia> import JuliaPythonAdaptor  

# find the python I specified in $PATH
julia> using PythonCall   

```

However, it turns out to be difficult when working with precompilation.

Here is an MWE, and you could just create a small package referencing the two packages:

```julia
#= install deps: =#
import Pkg
Pkg.add(url=raw"https://github.com/thautwarm/JuliaPythonAdaptor.jl/")
Pkg.add("PythonCall")

#= my package's main module =#
module MyMWE
import JuliaPythonAdaptor
import PythonCall
end # module

```

The first time I imported `MyMWE`, things worked and the package got precompiled. Then, I won’t be able to import `MyMWE` any more , as `JuliaPythonAdaptor. __init__ ` is not called before loading `PythonCall`.

Although it is possible to use bash scripts to set environment variables before starting julia, I’d like to use a Julia package to implement the logic. I’m not stick to my current method, but my final goal is to ~~allow using a Julia package to configure the environment before loading PythonCall.~~ (EDIT) dynamically call some Julia code for setup, before loading PythonCall.

I wonder if this is possible without modifying the source code of PythonCall?
