Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add SageMath to pylance

I am using VSCode to write some SageMath code in a Jupyter notebook. Everything works fine and I can run my code but Pylance underlines all Sage imports and reports them as missing

I have tried adding the path (/Applications/SageMath-9-8.app/Contents/Frameworks/Sage.framework/Versions/9.8/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages) in Python > Analysis: Extra Paths (which worked for python's auto-complete support) but it didn't work in this case. I am aware that I can stop Pylance from reporting missing imports altogether but this is not what I want.

like image 715
George Giapitzakis Avatar asked Oct 16 '25 16:10

George Giapitzakis


1 Answers

Thanks for your question, because it helped me find where sagemath was hiding its site-packages file.

Building on this pylance issue on github, I ended up adding the magic words from sage.all import * to the top of my .sage file, and then Pylance suddenly started being happy with sage builtins.

like image 119
Spencer Bagley Avatar answered Oct 18 '25 09:10

Spencer Bagley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!