How to install a python package automatically in my package?

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:

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?

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

1 Like

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

1 Like

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?