# How to install a python package automatically in my package?

**URL:** <https://discourse.julialang.org/t/how-to-install-a-python-package-automatically-in-my-package/94581>\
**Category:** General Usage\
**Tags:** question, package, python, pythoncall\
**Created:** [February 13, 2023, 6:47pm UTC](https://discourse.julialang.org/t/how-to-install-a-python-package-automatically-in-my-package/94581 "2023-02-13T18:47:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iddingsite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iddingsite/32/31840_2.png) [@Iddingsite](https://discourse.julialang.org/u/Iddingsite)\
**Post date:** [February 13, 2023, 6:47pm UTC](https://discourse.julialang.org/t/how-to-install-a-python-package-automatically-in-my-package/94581/1 "2023-02-13T18:47:18Z")

</div>

Hi everyone,

I am writing a small package for a personel project. It is dependant on a python package that is wrapping another code written in Fortran.

I know how to install it via pip in PyCall.jl and it works great. But I would like to have a setup to install it automatically if someone download my package. I am not that experienced in Julia but I’ve read a bit about the \_\_ init \_\_ function that I could maybe put in my main module containing the code to install the python package.

Let’s say I want to install numpy as an example:

```julia
using PyCall
run(`$(PyCall.python) -m pip install --upgrade numpy`)

```

Would I just need to write this lines in the **init** function? What would be the best way to do it then?

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [February 13, 2023, 7:34pm UTC](https://discourse.julialang.org/t/how-to-install-a-python-package-automatically-in-my-package/94581/2 "2023-02-13T19:34:09Z")

</div>

By no means an expert here, but have you considered PythonCall.jl instead of PyCall.jl? I think it offers something like this

[https://cjdoris.github.io/PythonCall.jl/dev/pythoncall/#python-deps](https://cjdoris.github.io/PythonCall.jl/dev/pythoncall/#python-deps)

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [February 13, 2023, 8:00pm UTC](https://discourse.julialang.org/t/how-to-install-a-python-package-automatically-in-my-package/94581/3 "2023-02-13T20:00:25Z")

</div>

Indeed PythonCall offers a nicer way to manage dependencies (I would say that, I wrote it) but if you do want to use PyCall then `pyimport_conda` will install dependencies for you automatically when you import a package: [GitHub - JuliaPy/PyCall.jl: Package to call Python functions from the Julia language](https://github.com/JuliaPy/PyCall.jl#using-pycall-from-julia-modules)

---

<div class="post-metadata">

**Author:** ![Iddingsite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iddingsite/32/31840_2.png) [@Iddingsite](https://discourse.julialang.org/u/Iddingsite)\
**Post date:** [February 13, 2023, 8:14pm UTC](https://discourse.julialang.org/t/how-to-install-a-python-package-automatically-in-my-package/94581/4 "2023-02-13T20:14:13Z")

</div>

Thank you both for nice options. The thing that prevented me a bit from using PythonCall (while knowing nothing about the differences btw the 2 packages) was that it is not yet in 1.x.x version but appart from that, the packages seem quite equivalent. And reading a bit the docs, PythonCall seems indeed better for what I want. Is there a particular reason why it is not considered as production ready or something I should be aware of?
