Making PyCall and PythonCall work in the same project environment

Hi all,

I need to make PyCall and PythonCall work in the same script, because I am using both PyPlot, and AtomsIOPython which depend on PyCall and PythonCall, respectively.

I followed the tips on the PythonCall page to force PyCall to use the same interpreter as PythonCall, that is:

using PythonCall
ENV["PYTHON"] = PythonCall.python_executable_path()
] build PyCall

Now, I am trying to be cleaner in my management of dependencies, so instead of using the default environment, I am using a local one, with:

] activate .

I need to redo the same thing, but in this case, the PythonCall Python interpreter will be located in the my local project directory: "<local-project>/.CondaPkg/env/bin/python".

I am still learning how do environments and packages are working in Julia. But as far as I’ve understood, since the packages are shared across different environments, if I rebuild PyCall with this interpreter, then it will be used everytime, and not just in my local environment.

So my question is:

  • is it the case ? Did I understand correctly ?
  • what is the idiomatic way of dealing with this ? In some way, I need to “vendor” PyCall locally in my environment, but I do not know how to do it.
  • and side question, what would be the good practice to adopt with VCS ? I feel like I would not want to track with git the whole .CondaPkg directory because it contains binary files, but also I would like someone to reproduce my setup just by cloning the repo.

Thanks !

Just use PythonPlot.jl instead of PyPlot.jl

3 Likes

Add .CondaPkg to .gitignore

1 Like

PyCall uses either the Python version installed on your OS outside of Julia, or a version specific to Julia projects, but shared by all of them.

If these two options are not sufficient for you you must use PythonCall…

1 Like