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:
pip install local_package
However, when I run the following command in 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:
~/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:
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!