Unable to add PyCall to any environment

I added an issue to PyCall.jl but I think it is more likely that something has become messed up on my laptop

Basically, if I try to add PyCall to any environment, it fails with

ERROR: LoadError: PyCall not properly installed. Please run Pkg.build("PyCall")

and when I build it I get

Pkg.build("PyCall").
[ Info: Running `conda install -y numpy` in root environment
ERROR: LoadError: failed process: Process(setenv(`/Users/peter.wolf/miniconda3/envs/phinder/bin/conda install -y numpy` ,["XPC_FLAGS=0x0", "_CE_M=",

Looking for things to check. How could I have messed up the built in Python? How does PyCall find the built in Python?

Thanks in advance
Peter

Note that I am using the builtin Python

julia>ENV["PYTHON"]
""

I think you can isolate this error. Can you try

import Pkg
ENV["PYTHON"] = ""
Pkg.add("Conda")
import Conda
Conda.add("numpy")

?

Thank you JD. Full log here

If I understand this error, Conda.add(“numpy”) is failing because the Python version is inconsistent with several installed libraries

What Python does PyCall use by default? I thought the package contained a built-in libpython

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:

  - pypi/pypi::datasets==2.1.0=pypi_0

Specifications:

  - brotlipy -> python[version='>=2.7,<2.8.0a0|>=3.5,<3.6.0a0']
  - pyarrow -> python[version='>=3.10,<3.11.0a0|>=3.7.1,<3.8.0a0']
  - pytorch -> python[version='>=3.5,<3.6.0a0']
  - wheel -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=3.5,<3.6.0a0']

Your python: python=3.9

I also notice that Conda.jl is using an executable from one of my miniconda environments. How/why is it doing that? Phinder is not a currently active environment. Where is this information stored?

Process(setenv(/Users/peter.wolf/miniconda3/envs/phinder/bin/conda install -y numpy,...

Ah ha! Fixed it by removing pypi/pypi::datasets==2.1.0=pypi_0

Conda.rm("datasets")

I still don’t understand how Conda.jl and PyCall.jl choose their environment. But apparently I fixed the chosen one.

1 Like

Glad you got it, my next recommendation was removing the conflicting packages.

Yes, I was also trying to work out why it was choosing this miniconda environment. You can check and/or set the default value using Conda.ROOTENV.
See also Using a pre-existing Conda installation

By the way, CondaPkg.jl with PythonCall.jl is a more nuanced alternative to managing conda environments while calling python that’s work for me in the past.