Compatibility Issue with Python 3.12.6
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
首先,在 Windows 11 上使用列出的 Python、Julia、PySR 和 juliacall 版本重現提供的 PySRRegressor 範例,然後檢查 PythonCall traceback 和相容性資訊。完成的標準是:範例能夠完成 model.fit 並列印出最佳方程式,且不出現回報的 JuliaError,同時相關的相容性行為已記錄或由適當的測試涵蓋。
由索引模型根據 Issue 內容生成。
描述
Compatibility Issue with Python 3.12.6
I encountered a JuliaError when trying to fit the PySRRegressor model using the PythonCall package. The error seems to be related to the compatibility of the PythonCall package with Python version 3.12.6.
Steps to Reproduce:
1- Install Python 3.12.6.
2- Install the pysr package using pip install pysr.
3- Run the following code:
import numpy as np
from pysr import PySRRegressor
Sample data
X = np.random.rand(100, 1) # 100 samples, 1 feature
y = 3.0 * X[:, 0] + 2.0 # Example target
Initialize PySR model
model = PySRRegressor(
niterations=100, # Number of iterations
binary_operators=["+", "-", "*", "/"], # Allowed binary operators
unary_operators=["sin", "exp", "log"], # Allowed unary operators
loss="L2", # Loss function (mean squared error)
populations=10, # Number of populations
procs=4, # Number of CPU cores to use
parsimony=0.01, # Encourages simpler equations
maxsize=20, # Maximum size of the equation
)
Fit the model
model.fit(X, y)
View the best equation
print("Best equation:", model.sympy())
View the Hall of Fame (top equations)
print(model)
.
.
Expected Behavior: The PySRRegressor model should fit the data without any errors, and the best equation should be printed.
Actual Behavior: The following error occurs:
JuliaError Traceback (most recent call last)
Cell In[34], line 22
10 model = PySRRegressor(
11 niterations=100, # Number of iterations
12 binary_operators=["+", "-", "*", "/"], # Allowed binary operators
(...)
18 maxsize=20, # Maximum size of the equation
19 )
21 # Fit the model
---> 22 model.fit(X, y)
24 # View the best equation
25 print("Best equation:", model.sympy())
File c:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\pysr\sr.py:2279, in PySRRegressor.fit(self, X, y, Xresampled, weights, variable_names, complexity_of_variables, X_units, y_units, category)
2276 self._checkpoint()
2278 # Perform the search:
-> 2279 self._run(X, y, runtime_params, weights=weights, seed=seed, category=category)
2281 # Then, after fit, we save again, so the pickle file contains
2282 # the equations:
2283 if not self.temp_equation_file:
File c:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\pysr\sr.py:1889, in PySRRegressor.run(self, X, y, runtime_params, weights, category, seed)
1886 if isinstance(complexity_of_variables, list):
1887 complexity_of_variables = jl_array(complexity_of_variables)
...
@ PythonCall.JlWrap C:\Users\Administrator.julia\packages\PythonCall\Nr75f\src\JlWrap\module.jl:13
[5] pyjl_callmethod(f::Any, self::Ptr{PythonCall.C.PyObject}, args::Ptr{PythonCall.C.PyObject}, nargs::Int64)
@ PythonCall.JlWrap C:\Users\Administrator.julia\packages\PythonCall\Nr75f\src\JlWrap\base.jl:67
[6] _pyjl_callmethod(o::Ptr{PythonCall.C.PyObject}, args::Ptr{PythonCall.C.PyObject})
@ PythonCall.JlWrap.Cjl C:\Users\Administrator.julia\packages\PythonCall\Nr75f\src\JlWrap\C.jl:63
.
.
.
.
Environment:
-Python version: 3.12.6
-julia version: 1.11.2
-pysr version: 1.3.1
-juliacall version: 0.9.23
-Operating System: [Windows 11 64-bit]
.
.
.
julia> Base.versioninfo()
ERROR: UndefVarError: versioninfo not defined in Base
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] getproperty(x::Module, f::Symbol)
@ Base .\Base.jl:42
[2] top-level scope
@ REPL[1]:1
.
.
.
julia> Pkg.status()
ERROR: UndefVarError: Pkg not defined in Main
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] top-level scope
@ REPL[2]:1
.
.
.
julia> versioninfo()
Julia Version 1.11.2
Commit 5e9a32e7af (2024-12-01 20:02 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 16 × AMD Ryzen 7 4800H with Radeon Graphics
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, znver2)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
Environment:
JULIA_PATH = "D:\Backup\Downloads\julia-1.11.2-win64.exe"
.
.
.
Additional Information: I have verified that the JULIA_PATH environment variable is set correctly and that Julia is accessible from the command line. The issue seems to be specific to the compatibility of the PythonCall package with Python 3.12.6.
- 主要語言
- Julia
- 星號
- 1.1k
- 分支
- 89
- 平均合併
- 2 天 15 小時
- 30 天內合併 PR
- 7
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
JuliaPy/PythonCall.jl 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 55/100
JuliaPy/PythonCall.jl#828 · 7 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 48/100
JuliaPy/PythonCall.jl#809 · 2 則留言 ·
維護者通常 1 天內回覆
-
enhancement
難度 5/5 一週以上 新手友好度 35/100
JuliaPy/PythonCall.jl#805 · 4 則留言 ·
維護者通常 1 天內回覆
-
enhancement
難度 3/5 1-2 天 新手友好度 68/100
JuliaPy/PythonCall.jl#796 ·
維護者通常 1 天內回覆
-
enhancement
難度 5/5 一週以上 新手友好度 25/100
JuliaPy/PythonCall.jl#790 ·
維護者通常 1 天內回覆
查看 JuliaPy/PythonCall.jl 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
oxfordcontrol/COSMO.jl#211 ·
-
documentation
難度 2/5 半天 新手友好度 65/100
維護者通常 6 天內回覆
-
ARKODE: callbacks that modify `u` throw MethodError on reinit可能已有人在做 @devmotion 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 79/100
SciML/Sundials.jl#575 ·
-
難度 1/5 1 小時以內 新手友好度 78/100
維護者通常 1 天內回覆
-
Tube(N) builds N TubeBase segments of length L/(N−1): total friction/inertia length is N·L/(N−1)可能已有人在做 @ChrisRackauckas-Claude 今天認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 78/100
SciML/ModelingToolkitStandardLibrary.jl#525 ·
維護者通常 1 天內回覆