Setting up PySR and PySINDy environment for the Symbolic Model Discovery workshop.
If you're confident with Python and setting up virtual environment, set a virtual environment up and run GettingStarted.ipynb
in the virtual environment.
If you're not familiar with setting up virtual environment, follow the procedure below using VS Code.
-
(Install Python - Recommended version: 3.13.x ) Most Linux distro and Mac has python pre-installed. You may skip this step if your Python version is 3.11+
-
Install VS Code and open it. We use Visual Studio Code to guide you through the rest of the installation process.
-
Go to
Extensions
(4th/5th/6th button on the left toolbar) and installPython
,Python Environments
andJupyter
extensions. -
Clone this repo and change directory to this folder.
-
For those using WSL or on Linux, the command is
git clone https://github.com/SymbolicModel/GettingStarted.git cd GettingStarted
-
-
Open the
GettingStarted
folder in VS Code and openGettingStarted.ipynb
. -
On the top right corner, select "Select Kernel", and follow the drop-down menu to "Python Environments...--> Create Python Environment --> venv --> Python 3.xx.xx" to create a local Python Environment.
- If you cannot find the "Python Environment" option, make sure you have
Python
,Python Environments
andJupyter
extensions installed.
- If you cannot find the "Python Environment" option, make sure you have
-
Run the first cell of
GettingStarted.ipynb
to install the necessary packages.- Note that for
PySR
, a JULIA backend will be installed automatically only upon first import. Follow through the rest of teh notebook to finish the install.
- Note that for
-
Run the rest of the notebook to finish the install and test the installation.
A successful run will have learning outputs from PySR
and PySINDy
. Compare the output with the version on Github.
- Install VS Code and the WSL extension in VS Code.
- Install WSL
- Open PowerShell in administrator mode by right-clicking and selecting "Run as administrator", enter the
wsl --install
command, then restart your machine. - Open PowerShell or Terminal (not in administrator mode) and type in
wsl --install Ubuntu-24.04
.- You will be prompted to create a user name and password for the Linux system.
- Open PowerShell in administrator mode by right-clicking and selecting "Run as administrator", enter the
- Open a WSL terminal window (using the start menu and navigate to
Ubuntu
or by typingwsl
from a command prompt / PowerShell). - Install
pip
andvenv
using the following commandsudo apt update; sudo apt install -y python3-pip python3-venv
- You will be prompted for password. Use the one you've just created in the previous step.
- Type
code
to open a VS Code. Goes to Extension and clickReload
under the WSL extension. (Skip this step if WSL extension is already up-to-date.) - Follow the rest of the guide above for Linux, starting from step 2.
This option will require that you know your way around installing Python properly on your Windows Machine, setting up a virtual environment and a Python Notebook environment. If you do, please make sure you have
- Python 3.11 or above (3.13 recommended)
- Set up a Jupyter Notebook environment, through VS Code or JupyterHub.
- With Matplotlib support
- Set up a Python virtual environment and install the latest version of the following packages
- numpy
- scipy
- pysr
- pysindy
- pandas
- matplotlib
First, clone this repo:
git clone https://github.com/SymbolicModel/GettingStarted.git
Then open VSCode:
code
Install the 'Jupyter', 'Python Environments' and 'Python' extensions, then open GettingStarted.ipynb
and, in the top right, click on where it says 'Python 3.x.xx'. This will bring up a prompt to choose a kernel from the ones available, or to 'Select another Kernel'. If one of the kernels available is named .venv
, choose that one. Otherwise, click 'Select another Kernel' and choose the newest version of python available. Then you should be able to run the notebook!
If your system is using a Python version older than 3.11, you may run into issues. In this case, consider the following options:
Linux/Mac:
- Install PyEnv following the procedure on the website to install a separate Python version (3.13.xx recommended).
- PyEnv may require build dependency to be installed first.
- For linux, these dependency are usually installed with a single command on the package manager.
- For Mac, you may need to first enable developer options (
xcode-select --install
) and install homebrew.
Mac:
- Installing custom python version via homebrew directly is an alternative to PyEnv if you already have homebrew installed.
Windows (non-WSL):
- Download and install the latest Python version 3.13 and retry.
If you have run out of storage on your C:\ drive, WSL installation will fail. To install WSL on another drive, first find the Ubuntu 24.04 link on this page and copy the link to download the distribution, which should look something like https://aka.ms/wslubuntu
. Move it to a space on your preferred drive. Then run Powershell as an administrator (right click -> 'run as administrator') and type the following commands:
Set-Location D:
- This sets the current working directory (cwd) to the D: drive. If you want to use a different drive, replace the
D:
with the name of that drive.
New-Item WSL -Type Directory
- This creates a folder to store our new WSL installation in.
Set-Location .\WSL
- This moves our cwd to our new folder.
curl -L -o Linux.appx <distribution_url>
- This will download the distribution from the link that we found earlier, and put it in a file called
Linux.appx
.
Copy-Item .\Linux.appx .\Linux.zip
- Makes a backup copy of our linux distribution.
Expand-Archive .\Linux.zip
- Extracts our Linux distribution so that we can use the files in it.
Get-Childitem -Filter *.exe
- Looks for an executable file that we can use to run WSL from.
Once you have found the executable, which should be called
ubuntu.exe
, run it (by typingubuntu.exe
into either Powershell or cmd) and you should have a working terminal where you can type commands. It might be the case thatGet-Childitem -Filter *.exe
does not return any results. If this happens, set your cwd to the newLinux
folder:
Set-Location Linux
Then look for an appx
-extension file:
Get-Childitem -Filter *.appx
Then rename it to .zip
so that we can extract it e.g.:
ren .\Ubuntu_2404.x.x.xx.appx .\Ubuntu_2404.zip
Extract the new file:
Expand-Archive .\Ubuntu_2404.zip
Set cwd to the new folder created by the extraction:
Set-Location .\Ubuntu_2404
Now we should be able to see the executable:
Get-Childitem -Filter *.exe
And then we can run it:
ubuntu.exe
It's possible that your WSL installation comes without pip, which will mean when you try to pip install pysr
you will see an 'unknown command' error. To fix this, you'll need to install pip yourself.
Try to use the following command to install pip:
sudo apt update; sudo apt install -y python3-pip python3-venv
If that doesn't work, try the following:
- Try running
python3 -m ensurepip --upgrade
in your ubuntu terminal. - If that doesn't work, you need to run the command
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
to create a python file called 'get-pip'. Run it withpython3 -m get-pip
. Check that it's installed properly by runningpip install pysr
. If that doesn't work, try runningpython3 -m pip install pysr
. You should now be able to install packages to your ubuntu distribution.
It is recommended that you at least attempt to install Python and the packages locally. If all attempts fail, you may fall back on Google Colab as a working environment.
Setting up - Simply run the GettingStarted.ipynb
on this link.