MilesCranmer / PySR

High-Performance Symbolic Regression in Python and Julia
https://astroautomata.com/PySR
Apache License 2.0
2.19k stars 207 forks source link

Jupyter error "tried to read a stream that is not readable" #250

Closed MilesCranmer closed 1 year ago

MilesCranmer commented 1 year ago

Discussed in https://github.com/MilesCranmer/PySR/discussions/248

Originally posted by **quasars100** January 15, 2023 Hi, Sorry this is a basic question about installation - I followed all instructions (Julia was already installed, then I ran "pip install -U pysr" followed by " python -c 'import pysr; pysr.install()' "). There was no issues regarding importing Pysr in python; however, when I try running model = PySRRegressor( niterations=40, # < Increase me for better results binary_operators=["+", "*"], unary_operators=[ "cos", "exp", "sin", "inv(x) = 1/x", # ^ Custom operator (julia syntax) ], extra_sympy_mappings={"inv": lambda x: 1 / x}, # ^ Define operator for SymPy as well loss="loss(x, y) = (x - y)^2", # ^ Custom loss function (julia syntax) ) model.fit(x,y) the following error appeared: RuntimeError: One reason might be that my Julia version is currently 1.8.5 instead of 0.6.0 (which isn't supported anymore, when I tried to downgrade the current version), or it could be another issue. Is there any way to fix the issue? When I tried running the code with an older Julia version (1.0), it said I had to update Julia first. Thank you.
MilesCranmer commented 1 year ago

The watch_stream should be wrapped in a try-catch to avoid this. It’s not immediately apparent how to actually get it working within Jupyter… maybe it needs a button to stop the search, rather than watching for “q”.