# Error when calling ScikitLearn from a function in a Package

**URL:** <https://discourse.julialang.org/t/error-when-calling-scikitlearn-from-a-function-in-a-package/46131>\
**Category:** General Usage\
**Tags:** package\
**Created:** [September 6, 2020, 7:00am UTC](https://discourse.julialang.org/t/error-when-calling-scikitlearn-from-a-function-in-a-package/46131 "2020-09-06T07:00:52Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [September 7, 2020, 8:41am UTC](https://discourse.julialang.org/t/error-when-calling-scikitlearn-from-a-function-in-a-package/46131/6 "2020-09-07T08:41:52Z")

</div>

This looks related,

> [@Imported ScikitLearn PyObj becomes NULL in a module](https://discourse.julialang.org/t/imported-scikitlearn-pyobj-becomes-null-in-a-module/30942/2):
>
> Yeah that’s tricky, you need to place the import in the init function, see how I did it here [https://github.com/baggepinnen/HDBSCAN.jl/blob/master/src/HDBSCAN.jl](https://github.com/baggepinnen/HDBSCAN.jl/blob/master/src/HDBSCAN.jl)

I tried doing this, but is not working:

```julia
    using ScikitLearn, PyCall
    const LogisticRegression = PyNULL()
    function __init__ ()
        @eval global LogisticRegression = pyimport("linear_model")
    end

```

Gives this error:

```julia
  Got exception outside of a @test
  LoadError: InitError: PyError (PyImport_ImportModule
  
  The Python package linear_model could not be found by pyimport. Usually this means
  that you did not install linear_model in the Python version being used by PyCall.

```

---

_[View the full topic](https://discourse.julialang.org/t/error-when-calling-scikitlearn-from-a-function-in-a-package/46131)._
