How to install pySR on python(Windows system)

Hi,everyone. I am very new to pysr and julia. When I installed pysr by using the command “pip install pysr”, and imported it in python, it told that Command ‘[‘C:\Users\wilson\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\bin\julia.exe’, ‘–project=D:\Users\wilson\anaconda3\envs\SR\julia_env’, ‘–startup-file=no’, ‘-e’, ‘import Pkg; Pkg.Registry.update(); Pkg.add([Pkg.PackageSpec(name=“PythonCall”, uuid=“6099a3de-0909-46bc-b1f4-468b9a2dfc0d”), Pkg.PackageSpec(name=“SymbolicRegression”, uuid=“8254be44-1295-4e6a-a16d-46603ac705cb”), Pkg.PackageSpec(name=“Serialization”, uuid=“9e88b42a-f829-5b0c-bbe9-9e923198166b”)]); Pkg.resolve(); Pkg.precompile()’]’ returned non-zero exit status 1.

I don’t know where the problem is. Could anyone please help me fix it? Thanks!

1 Like

I’m tagging @MilesCranmer for help with this.

  1. Can you show the rest of the error message? The current printout just says it has an error but doesn’t specify what error.
  2. What version of PySR?
  3. It looks like you’re using conda. So why not use conda install -c conda-forge pysr? The pip one is meant for non-conda environments.

[juliapkg] Found dependencies: d:\users\wilson\anaconda3\envs\sr\lib\site-packages\juliapkg\juliapkg.json
[juliapkg] Found dependencies: d:\users\wilson\anaconda3\envs\sr\lib\site-packages\juliacall\juliapkg.json
[juliapkg] Found dependencies: d:\users\wilson\anaconda3\envs\sr\lib\site-packages\pysr\juliapkg.json
[juliapkg] Locating Julia ~1.6.7, ~1.7, ~1.8, ~1.9, =1.10.0, ^1.10.3
[juliapkg] Using Julia 1.10.4 at C:\Users\wilson.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\bin\julia.exe
[juliapkg] Using Julia project at D:\Users\wilson\anaconda3\envs\SR\julia_env
[juliapkg] Installing packages:
julia> import Pkg
julia> Pkg.Registry.update()
julia> Pkg.add([Pkg.PackageSpec(name=“PythonCall”, uuid=“6099a3de-0909-46bc-b1f4-468b9a2dfc0d”), Pkg.PackageSpec(name=“SymbolicRegression”, uuid=“8254be44-1295-4e6a-a16d-46603ac705cb”), Pkg.PackageSpec(name=“Serialization”, uuid=“9e88b42a-f829-5b0c-bbe9-9e923198166b”)])
julia> Pkg.resolve()
julia> Pkg.precompile()

”””

CalledProcessError Traceback (most recent call last)
Cell In[9], line 1
----> 1 import pysr

File D:\Users\wilson\anaconda3\envs\SR\Lib\site-packages\pysr_init_.py:4
1 # This must be imported as early as possible to prevent
2 # library linking issues caused by numpy/pytorch/etc. importing
3 # old libraries:
----> 4 from .julia_import import jl, SymbolicRegression # isort:skip
6 from . import sklearn_monkeypatch
7 from .deprecated import best, best_callable, best_row, best_tex, install, pysr

File D:\Users\wilson\anaconda3\envs\SR\Lib\site-packages\pysr\julia_import.py:45
41 if autoload_extensions is not None:
42 # Deprecated; so just pass to juliacall
43 os.environ[“PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION”] = autoload_extensions
—> 45 from juliacall import Main as jl # type: ignore
47 jl = cast(ModuleType, jl)
50 jl_version = (jl.VERSION.major, jl.VERSION.minor, jl.VERSION.patch)

File D:\Users\wilson\anaconda3\envs\SR\Lib\site-packages\juliacall_init_.py:277
274 import juliacall.ipython
275 juliacall.ipython.load_ipython_extension(ip)
→ 277 init()

File D:\Users\wilson\anaconda3\envs\SR\Lib\site-packages\juliacall_init_.py:158, in init()
155 import juliapkg
157 # Find the Julia executable and project
→ 158 CONFIG[‘exepath’] = exepath = juliapkg.executable()
159 CONFIG[‘project’] = project = juliapkg.project()
161 # Find the Julia library

File D:\Users\wilson\anaconda3\envs\SR\Lib\site-packages\juliapkg\deps.py:364, in executable()
363 def executable():
→ 364 resolve()
365 return STATE[“executable”]

File D:\Users\wilson\anaconda3\envs\SR\Lib\site-packages\juliapkg\deps.py:336, in resolve(force, dry_run)
331 if sys.executable:
332 # prefer PythonCall to use the current Python executable
333 # TODO: this is a hack, it would be better for PythonCall to detect that
334 # Julia is being called from Python
335 env.setdefault(“JULIA_PYTHONCALL_EXE”, sys.executable)
→ 336 run(
337 [exe, “–project=” + project, “–startup-file=no”, “-e”, "; ".join(script)],
338 check=True,
339 env=env,
340 )
341 # record that we resolved
342 save_meta(
343 {
344 “meta_version”: META_VERSION,
(…)
355 }
356 )

File D:\Users\wilson\anaconda3\envs\SR\Lib\subprocess.py:571, in run(input, capture_output, timeout, check, *popenargs, **kwargs)
569 retcode = process.poll()
570 if check and retcode:
→ 571 raise CalledProcessError(retcode, process.args,
572 output=stdout, stderr=stderr)
573 return CompletedProcess(process.args, retcode, stdout, stderr)

CalledProcessError: Command ‘[‘C:\Users\wilson\.julia\juliaup\julia-1.10.4+0.x64.w64.mingw32\bin\julia.exe’, ‘–project=D:\Users\wilson\anaconda3\envs\SR\julia_env’, ‘–startup-file=no’, ‘-e’, ‘import Pkg; Pkg.Registry.update(); Pkg.add([Pkg.PackageSpec(name=“PythonCall”, uuid=“6099a3de-0909-46bc-b1f4-468b9a2dfc0d”), Pkg.PackageSpec(name=“SymbolicRegression”, uuid=“8254be44-1295-4e6a-a16d-46603ac705cb”), Pkg.PackageSpec(name=“Serialization”, uuid=“9e88b42a-f829-5b0c-bbe9-9e923198166b”)]); Pkg.resolve(); Pkg.precompile()’]’ returned non-zero exit status 1.

”””



  1. Version: 0.19.0
  2. Do I need to uninstall it and use conda to install again?

Can you wrap your error message with triple backquotes? It’s hard to read otherwise. You can edit your posts.

I would at least try this. i.e., pip uninstall pysr and then the conda version I sent above

I tried again with conda, but still encountered the same error. Notably, after downloading pysr, when importing it into Python, it will automatically install the Julia dependencies. Also, I have edited the screenshot of the error above, do you think this makes it clearer?

Can you try manually running the Julia command it is trying to execute? Basically, can you start Julia itself, outside of Python? (And if not, what’s the error?)

I can run Julia independently from Python. However, when attempting to execute certain commands, I encountered some errors.



Thanks! So that would explain the PySR error. It seems you can’t connect to the Julia registry. Do you have a firewall or other thing blocking your connection to the julialang website?

I’m not sure about this. I’m attempting to install Julia manually, but I don’t know how to manage the environment. Perhaps I should uninstall the previous Julia installation, but that seems a bit complex.

Where are you located approximately? I’m wondering if we could point you to a more convenient pkg server.

For now, could you try this:

ENV["JULIA_PKG_SERVER"] = ""
using Pkg
Pkg.Registry.update()

Also see

I’m from Zhengzhou, China.






Ah, yes, this makes complete sense now.

Please see

Perhaps @JohnnyChen94 could provide further advice.

1 Like

(If this works, I wonder if PySR and maybe pyjuliapkg in general should use PkgServerClient.jl as a fallback option)

Can you try installing from GitHub instead, using the following?

]add https://github.com/johnnychen94/PkgServerClient.jl

I’m guessing GitHub is not blocked so perhaps this will work.

Oh, sorry, maybe instead, can you try setting JULIA_PKG_SERVER explicitly? I guess it needs it even to check the dependencies.

Maybe try the Nanjing University one from the PkgServerClient.jl list, which looks to be live: NJU Mirror

julia> ENV["JULIA_PKG_SERVER"] = "https://mirrors.nju.edu.cn/julia";

julia> using Pkg

julia> Pkg.Registry.update()

If that works, you can set it globally in your environment variables. Maybe the PySR installation will “just work” then.

2 Likes

It worked! Thank you very much for taking the time to help me solve the problem! :smile: :heart:

1 Like

Awesome!

(I wonder if there is an automated way I can detect this error automatically from PySR and suggest setting that env variable…)