# PyCall import local package

**URL:** <https://discourse.julialang.org/t/pycall-import-local-package/127440>\
**Category:** New to Julia\
**Tags:** pycall\
**Created:** [March 28, 2025, 9:16am UTC](https://discourse.julialang.org/t/pycall-import-local-package/127440 "2025-03-28T09:16:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![larstz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/larstz/32/215012_2.png) [@larstz](https://discourse.julialang.org/u/larstz)\
**Post date:** [March 28, 2025, 9:16am UTC](https://discourse.julialang.org/t/pycall-import-local-package/127440/1 "2025-03-28T09:16:01Z")

</div>

Hi everyone,

I’m having trouble importing a local Python package using PyCall in Julia. I have a working Python environment where I’ve successfully installed my local package with the command:

```julia
pip install local_package

```

However, when I run the following command in Julia:

```julia
julia -e 'using Pkg; Pkg.add("PyCall"); using PyCall; @pyimport local_package;'

```

I encounter an error stating that the Python package could not be found. The error message also indicates that PyCall is configured to use the Python version located at: `~/micromamba/envs/swe/bin/python3`.  
Interestingly, when I test the environment directly by running:

```julia
~/micromamba/envs/swe/bin/python3 -c "import local_package; print(local_package. __version__ )"

```

the import works perfectly, and I get the expected version number as output.  
If I try importing another package from that environment, e.g., `@pyimport numpy` I don’t get and error and the import works just fine.

A workaround I found was to use the following command before importing my local package:

```julia
pushfirst!(PyVector(pyimport("sys")["path"]), "")

```

I would’ve expected PyCall to find all the packages installed in the environment python PyCall uses? Are there any steps I can take to ensure that PyCall recognizes my local package, without the need to change the sys.path variable?

Thank you!
