# How to install pySR on python(Windows system)

**URL:** https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952
**Category:** New to Julia
**Tags:** question
**Created:** [July 12, 2024, 8:41am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952 "2024-07-12T08:41:49Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![wilson](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@wilson](https://discourse.julialang.org/u/wilson)
#### Post date: [July 12, 2024, 8:41am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/1 "2024-07-12T08:41:49Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [July 12, 2024, 9:58am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/2 "2024-07-12T09:58:08Z")

</div>

I’m tagging @MilesCranmer for help with this.

---

<div class="post-metadata">

### Author: ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)
#### Post date: [July 12, 2024, 11:01am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/3 "2024-07-12T11:01:31Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![wilson](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@wilson](https://discourse.julialang.org/u/wilson)
#### Post date: [July 12, 2024, 11:18am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/4 "2024-07-12T11:18:25Z")

</div>

1. 

[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](https://global.discourse-cdn.com/julialang/original/3X/0/4/04356a28dc3092ce07ea2b9f7a57c08246887a79.png)  
 ![2](https://global.discourse-cdn.com/julialang/original/3X/9/2/922b0e2e7578a52f705ce77655120a63893c3b8d.png)  
 ![3](https://global.discourse-cdn.com/julialang/original/3X/7/7/77af3e728b6df65c41171d0bd2ac9f9b5df4ab18.png)

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

---

<div class="post-metadata">

### Author: ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)
#### Post date: [July 12, 2024, 11:32am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/5 "2024-07-12T11:32:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)
#### Post date: [July 12, 2024, 11:33am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/6 "2024-07-12T11:33:17Z")

</div>

> [@wilson](#):
>
> Do I need to uninstall it and use conda to install again？

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

---

<div class="post-metadata">

### Author: ![wilson](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@wilson](https://discourse.julialang.org/u/wilson)
#### Post date: [July 12, 2024, 12:49pm UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/7 "2024-07-12T12:49:28Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)
#### Post date: [July 12, 2024, 6:20pm UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/8 "2024-07-12T18:20:52Z")

</div>

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?)

---

<div class="post-metadata">

### Author: ![wilson](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@wilson](https://discourse.julialang.org/u/wilson)
#### Post date: [July 13, 2024, 2:21am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/9 "2024-07-13T02:21:08Z")

</div>

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

 ![1](https://global.discourse-cdn.com/julialang/original/3X/f/e/fe4da1bef1345945d666940b35d710ea271e1f3e.png)  
 ![2](https://global.discourse-cdn.com/julialang/original/3X/3/9/3965697759e19ae426199ec87a46d3ce60c33ef4.png)  
 ![3](https://global.discourse-cdn.com/julialang/original/3X/8/4/84cc85518ed1fa3c20ff741d65b9dc27508a361d.png)

---

<div class="post-metadata">

### Author: ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)
#### Post date: [July 13, 2024, 2:28am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/10 "2024-07-13T02:28:15Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![wilson](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@wilson](https://discourse.julialang.org/u/wilson)
#### Post date: [July 13, 2024, 9:10am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/11 "2024-07-13T09:10:42Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [July 13, 2024, 10:11am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/12 "2024-07-13T10:11:40Z")

</div>

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:

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

```

Also see

> **[GitHub - johnnychen94/PkgServerClient.jl: A smart PkgServer 🎉](https://github.com/johnnychen94/PkgServerClient.jl)**
>
> A smart PkgServer 🎉. Contribute to johnnychen94/PkgServerClient.jl development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![wilson](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@wilson](https://discourse.julialang.org/u/wilson)
#### Post date: [July 13, 2024, 11:04am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/13 "2024-07-13T11:04:38Z")

</div>

I’m from Zhengzhou, China.

 ![6](https://global.discourse-cdn.com/julialang/original/3X/0/7/07f2f5e764e31c8cf47670f7dc6e207b871e676a.png)  
 ![0](https://global.discourse-cdn.com/julialang/original/3X/4/5/455208a0c5ac2a599b973a2538a381969c92590e.png)  
 ![01](https://global.discourse-cdn.com/julialang/original/3X/7/0/7053e79d07c0657e8b4837495927fe70806e7ad1.png)  
 ![7](https://global.discourse-cdn.com/julialang/original/3X/1/d/1d5355d066b5b215bf7fb50c9b6550f4e6820ae5.png)  
 ![8](https://global.discourse-cdn.com/julialang/original/3X/5/f/5fa813d7841215faca0018c2dcfe0c0b21e51177.png)  
 ![9](https://global.discourse-cdn.com/julialang/original/3X/5/b/5bd7a5861b9455576d31cc001409f1dba7150863.png)

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [July 13, 2024, 11:07am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/14 "2024-07-13T11:07:04Z")

</div>

Ah, yes, this makes complete sense now.

Please see

> <https://github.com/johnnychen94/PkgServerClient.jl/blob/master/README_zh.md>

Perhaps @JohnnyChen94 could provide further advice.

---

<div class="post-metadata">

### Author: ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)
#### Post date: [July 13, 2024, 1:29pm UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/15 "2024-07-13T13:29:06Z")

</div>

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

---

<div class="post-metadata">

### Author: ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)
#### Post date: [July 13, 2024, 1:31pm UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/16 "2024-07-13T13:31:56Z")

</div>

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

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

```

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

---

<div class="post-metadata">

### Author: ![wilson](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@wilson](https://discourse.julialang.org/u/wilson)
#### Post date: [July 13, 2024, 2:23pm UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/17 "2024-07-13T14:23:02Z")

</div>

![02](https://global.discourse-cdn.com/julialang/original/3X/1/d/1d5aa6f7b43a85243c890a3eb9ff0766ea6c1dbc.png)

---

<div class="post-metadata">

### Author: ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)
#### Post date: [July 13, 2024, 7:24pm UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/18 "2024-07-13T19:24:46Z")

</div>

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](https://mirrors.nju.edu.cn/julia)

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

---

<div class="post-metadata">

### Author: ![wilson](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@wilson](https://discourse.julialang.org/u/wilson)
#### Post date: [July 14, 2024, 12:54am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/19 "2024-07-14T00:54:31Z")

</div>

It worked! Thank you very much for taking the time to help me solve the problem! 😄 ❤

---

<div class="post-metadata">

### Author: ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)
#### Post date: [July 14, 2024, 1:05am UTC](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952/20 "2024-07-14T01:05:21Z")

</div>

Awesome!

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

[Next page](https://discourse.julialang.org/t/how-to-install-pysr-on-python-windows-system/116952.md?page=2)
