PyCall No system-wide Python was found

Hello Julia/PyCall team,

trying to add the PyCall package I get the error

build.log` [>                                        ]  0/2
ERROR: Error building `PyCall`:
┌ Info: No system-wide Python was found; got the following error:
│ Base.IOError("could not spawn setenv(`'C:\\ProgramData\\Anaconda3' -c \"import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSIO
N'))\"`,[\"PATH=C:\\\\Windows\\\\system32;C:\\\\Windows;C:\\\\Windows\\\\System32\\\\Wbem;C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\;C

....


.... "]): no such file or directory (ENOENT)", -4058)
└ using the Python distribution in the Conda package
[ Info: Running `conda install -y numpy` in root environment
ERROR: LoadError: failed process: Process(setenv(`'C:\Users\Giovanni Pietrobon\.julia\conda\3\Scripts\conda.exe' install -y numpy`,["PATH=C:\\Users\\Giovanni Pietrobon\\.julia\\conda\\3\\Library\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShe

.....

"]), ProcessExited(3221225595)) [3221225595]


Stacktrace:
 [1] pipeline_error
   @ .\process.jl:525 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base .\process.jl:440
 [3] run
   @ .\process.jl:438 [inlined]
 [4] runconda(args::Cmd, env::String)
   @ Conda C:\Users\Giovanni Pietrobon\.julia\packages\Conda\sNGum\src\Conda.jl:129
 [5] add(pkg::String, env::String; channel::String)
   @ Conda C:\Users\Giovanni Pietrobon\.julia\packages\Conda\sNGum\src\Conda.jl:221
 [6] add (repeats 2 times)
   @ C:\Users\Giovanni Pietrobon\.julia\packages\Conda\sNGum\src\Conda.jl:220 [inlined]
 [7] top-level scope
   @ C:\Users\Giovanni Pietrobon\.julia\packages\PyCall\3fwVL\deps\build.jl:79
 [8] include(fname::String)
   @ Base.MainInclude .\client.jl:444
 [9] top-level scope
   @ none:5


using Windows 7
64-bit
Julia 1.6.3
Anaconda3-2021.05-Windows-x86_64
antivirus disabled
rebooted quite a few times

Despite having tried (and read) all I could find, I’m still stuck.

I reinstalled everything from scratch. Even as administrator.
Installed Anaconda for all users (it seems things are going better)

I tried to go on python and update numpy, here’s the log

(base) C:\Users\Giovanni Pietrobon>conda update -y numpy
Collecting package metadata (current_repodata.json): done
Solving environment: \

Updating numpy is constricted by

anaconda -> requires numpy==1.20.1=py38h34a8a5c_0

If you are sure you want an update of your package either try `conda update --all` or install a specific version of the package you want using `conda
install <pkg>=<version>`

done

# All requested packages already installed.

Similarly I tried conda update --all from conda
It fails too.

Realizing that numpy is actually successfully installed on conda, I also tried to have PyCall to use that version and did set on Windows

set PYTHON = "C:\ProgramData\Anaconda3"

As they say somewhere I have to set it from Julia too:

ENV["PYTHON"] = raw"C:\ProgramData\Anaconda3"

I did it. (I wonder if it really make a difference…),
but still the error and the log is the same.

Why doesn’t find Python in first place??

Conda is installed in a directory without spaces, it should be found there,

I noticed that Julia then tries to install Miniconda, which happens to be in the .julia directory which is one with a space because of the username I use. I hope that is not the problem.

I also tried to add Matplotlib first, as described in
V1.4 failed to precompile PyCall and PyPlot on windows 7 x64
I did it successfully, but still PyCall build fails.

I didn’t try what suggested by temporaryred in
PyCall failing to build, cannot figure out solution. _ Julia

Should I try alternatives like suggested by @stevengj in
Dreaded PyCall build error ?
I’m not affectionate to anaconda at all, but I definitely need to use python too with data science.

Thank you for any help in advance.

Check if this complement of info can help.

Thank you,
your link prompted me to try and install miniforge3 instead (and disintall Anaconda)

I feel good about this solution, yet I got the error

Miniforge3 4.10.3-7 (64-bit) Setup
Failed to initialize Anaconda directories

which we can find with Anaconda, not with miniforge3.
While looking into it, have you by chance met this error already?

You may like to try GitHub - cjdoris/PythonCall.jl: Python and Julia in harmony. which manages its own Python installation for you. (This won’t help if you’re trying to use a package which depends on PyCall.)

The PYTHON env var should be set to the path of the Python executable itself, something like C:\ProgramData\Anaconda3\python.exe in your case I think.

I didn’t know about PythonCall. Definitely very good to know!

Also, the fact that PythonCall is installing and using separate Conda environments has been useful for me in order to better isolate the problem.

I digged into it, and described it in
Installation problems on Windows - The application was unable to start correctly (0xc000007b)

At the end I had to give up. I don’t know where things got screwed up, but I’m not so sure whether the problem is entirely due to my system, being that it works perfectly otherwise, even after changing username in order to get rid of the space it was having in it).

Thank you.