# Unable to add PyCall to any environment

**URL:** <https://discourse.julialang.org/t/unable-to-add-pycall-to-any-environment/83867>\
**Category:** General Usage\
**Tags:** pycall, python\
**Created:** [July 7, 2022, 12:52am UTC](https://discourse.julialang.org/t/unable-to-add-pycall-to-any-environment/83867 "2022-07-07T00:52:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter.wolf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/peter.wolf/32/6018_2.png) [@peter.wolf](https://discourse.julialang.org/u/peter.wolf)\
**Post date:** [July 7, 2022, 12:52am UTC](https://discourse.julialang.org/t/unable-to-add-pycall-to-any-environment/83867/1 "2022-07-07T00:52:13Z")

</div>

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

[https://github.com/JuliaPy/PyCall.jl/issues/994](https://github.com/JuliaPy/PyCall.jl/issues/994)

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

```julia
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
julia>ENV["PYTHON"]
""

```

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [July 7, 2022, 2:36am UTC](https://discourse.julialang.org/t/unable-to-add-pycall-to-any-environment/83867/2 "2022-07-07T02:36:10Z")

</div>

I think you can isolate this error. Can you try

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

```

?

---

<div class="post-metadata">

**Author:** ![peter.wolf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/peter.wolf/32/6018_2.png) [@peter.wolf](https://discourse.julialang.org/u/peter.wolf)\
**Post date:** [July 7, 2022, 3:31pm UTC](https://discourse.julialang.org/t/unable-to-add-pycall-to-any-environment/83867/3 "2022-07-07T15:31:00Z")

</div>

Thank you JD. Full log here

> **[isolate.log](https://drive.google.com/file/d/1n2JRd9UTyvEbjooOOpYo0TSq7KKcuGFa/view?usp=sharing)**
>
> Google Drive file.

---

<div class="post-metadata">

**Author:** ![peter.wolf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/peter.wolf/32/6018_2.png) [@peter.wolf](https://discourse.julialang.org/u/peter.wolf)\
**Post date:** [July 7, 2022, 3:40pm UTC](https://discourse.julialang.org/t/unable-to-add-pycall-to-any-environment/83867/4 "2022-07-07T15:40:52Z")

</div>

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

```julia
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

```

---

<div class="post-metadata">

**Author:** ![peter.wolf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/peter.wolf/32/6018_2.png) [@peter.wolf](https://discourse.julialang.org/u/peter.wolf)\
**Post date:** [July 7, 2022, 6:26pm UTC](https://discourse.julialang.org/t/unable-to-add-pycall-to-any-environment/83867/5 "2022-07-07T18:26:51Z")

</div>

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`,...`

---

<div class="post-metadata">

**Author:** ![peter.wolf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/peter.wolf/32/6018_2.png) [@peter.wolf](https://discourse.julialang.org/u/peter.wolf)\
**Post date:** [July 7, 2022, 6:44pm UTC](https://discourse.julialang.org/t/unable-to-add-pycall-to-any-environment/83867/6 "2022-07-07T18:44:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [July 8, 2022, 1:04am UTC](https://discourse.julialang.org/t/unable-to-add-pycall-to-any-environment/83867/7 "2022-07-08T01:04:20Z")

</div>

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

> [@peter.wolf](#):
>
> I still don’t understand how Conda.jl and PyCall.jl choose their environment.

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](https://github.com/JuliaPy/Conda.jl#using-a-pre-existing-conda-installation)

By the way, [CondaPkg.jl](https://github.com/cjdoris/CondaPkg.jl) with [PythonCall.jl](https://github.com/cjdoris/PythonCall.jl) is a more nuanced alternative to managing conda environments while calling python that’s work for me in the past.
