[BUG]: libpcre2-8 bug on Windows
zhuyi-bjut opened this issue · 9 comments
What happened?
I have been using the Julia1.9 version, and pysr can run normally
However, when I add the dimension calculation, the following error occurs:
RuntimeError Traceback (most recent call last)
Cell In[32], line 28
21 X = pd.DataFrame(dict(
22 M=M.to("M_sun").value,
23 m=m.to("kg").value,
24 r=r.to("R_earth").value,
25 ))
26 y = F.value
---> 28 model.fit(
29 X,
30 y,
31 X_units=["Constants.M_sun", "kg", "Constants.R_earth"],
32 y_units="kg * m / s^2"
33 )
File ~\AppData\Roaming\Python\Python311\site-packages\pysr\sr.py:1970, in PySRRegressor.fit(self, X, y, Xresampled, weights, variable_names, X_units, y_units)
1967 self._checkpoint()
1969 # Perform the search:
-> 1970 self._run(X, y, mutated_params, weights=weights, seed=seed)
1972 # Then, after fit, we save again, so the pickle file contains
1973 # the equations:
1974 if not self.temp_equation_file:
File ~\AppData\Roaming\Python\Python311\site-packages\pysr\sr.py:1800, in PySRRegressor._run(self, X, y, mutated_params, weights, seed)
1796 y_variable_names = [f"y{_subscriptify(i)}" for i in range(y.shape[1])]
1798 # Call to Julia backend.
1799 # See https://github.com/MilesCranmer/SymbolicRegression.jl/blob/master/src/SymbolicRegression.jl
-> 1800 self.raw_julia_state_ = SymbolicRegression.equation_search(
1801 Main.X,
1802 Main.y,
1803 weights=Main.weights,
1804 niterations=int(self.niterations),
1805 variable_names=self.feature_names_in_.tolist(),
1806 display_variable_names=self.display_feature_names_in_.tolist(),
1807 y_variable_names=y_variable_names,
1808 X_units=self.X_units_,
1809 y_units=self.y_units_,
1810 options=options,
1811 numprocs=cprocs,
1812 parallelism=parallelism,
1813 saved_state=self.raw_julia_state_,
1814 return_state=True,
1815 addprocs_function=cluster_manager,
1816 progress=progress and self.verbosity > 0 and len(y.shape) == 1,
1817 verbosity=int(self.verbosity),
1818 )
1820 # Set attributes
1821 self.equations_ = self.get_hof()
RuntimeError: <PyCall.jlwrap (in a Julia function called from Python)
JULIA: MethodError: no method matching _method_instances(::Type{typeof(*)}, ::Type{Tuple{SymbolicRegression.DimensionalAnalysisModule.WildcardQuantity{DynamicQuantities.Quantity{Float32, DynamicQuantities.Dimensions{DynamicQuantities.FixedRational{Int32, 25200}}}}, SymbolicRegression.DimensionalAnalysisModule.WildcardQuantity{DynamicQuantities.Quantity{Float32, DynamicQuantities.Dimensions{DynamicQuantities.FixedRational{Int32, 25200}}}}}})
The applicable method may be too new: running in world age 45094, while current world is 54814.
As #420 says, I replaced the julia version with 1.10.0 and the latest 1.10.3. However, the following errors occurred :
fatal: error thrown and no exception handler available.
InitError(mod=:Sys, error=ErrorException("could not load library "libpcre2-8"
The specified module could not be found. "))
ijl_errorf at C:/workdir/src\rtutils.c:77
just like #566 . I want to know which version of julia I should adjust when I want to introduce the dimension into pysr for calculation ? Thank you.
Version
0.16.3
Operating System
Windows
Package Manager
None
Interface
Jupyter Notebook
Relevant log output
No response
Extra Info
No response
Ah, this issue. This issue has been driving me crazy for a while. It only happens on Windows, and it's only for a few users.
It is a reported bug on Julia but with no solution: JuliaLang/julia#52205. Only a few users have reported it, and I really haven't been able to figure out what is special about those windows installations which causes this bug.
@tbuckworth were you ever able to solve this?
@zhuyi-bjut my advice is to try installing Julia a different way. My recommendation is to use JuliaUp: https://github.com/JuliaLang/juliaup.
You should make sure that juliacall is actually using the Julia version installed by JuliaUp. To do that you can use
import os
os.environ["PYTHON_JULIACALL_BINDIR"] = "/path/to/your/julia/bin/folder"
make sure to do this before you import PySR.
One thing I think might be happening is juliacall is installing a version without this particular dll for some reason. But if you can install the version yourself using juliaup I think it should carry it.
@cjdoris do you have any idea what this is? Sometimes PySR users on Windows will run into it. But only sometimes. I haven't been able to reproduce this once so I figure it must be something missing in the system libraries they have installed. Maybe juliacall is installing a julia binary without some dll?
Is this related at all I wonder: JuliaLang/julia#52007
The OP's error message is from PyCall not PythonCall - does that mean they are on an old version of PySR?
Oh I didn't even notice that, good catch!! Yeah @zhuyi-bjut the latest version of PySR is 0.18.4 but you are on 0.16.3. Can you please try upgrading?
I am very happy to tell you that I have solved this problem by updating the version of pysr ! Obviously I made a stupid mistake before. Anyway, thank you for your help @MilesCranmer @cjdoris
Awesome :)
@tbuckworth were you ever able to solve this?
No, I ended up installing Ubuntu instead
@tbuckworth if you try installing the latest PySR it might just work? (On Windows too)
Seems like @Angelld23 found a workaround on JuliaLang/julia#52007 (comment). Copying here for visibility:
import os import ctypes import glob
# Path to the bin directory of your Julia installation
julia_bin_path = "C:\path\to\your\dll_directory" # (which is the same as the julia.exe)
# Add the bin directory to PATH
os.environ["PATH"] += ";" + julia_bin_path
# Load each DLL file in the bin directory
for dll_path in glob.glob(os.path.join(julia_bin_path, "*.dll")):
try:
ctypes.CDLL(dll_path)
print(f"Loaded {dll_path} successfully.")
except OSError as e:
print(f"Could not load {dll_path}: {e}")
from pysr import PySRRegressor