How to install SymPy in Python?
In this tutorial, we will learn how to install SymPy in Python in different ways.
Python comes with a number of libraries that include functions and methods. You can import these in-built procedures to perform various tasks in your programs, easily.
SymPy is one such Python library that involves methods for symbolic mathematics. It is a wonderful tool for calculus and provides computer algebra functionalities to the users. It also provides methods for mathematical manipulations like expression simplification, computing derivatives, performing integrations, solving equations, etc.
In order to start learning and working with SymPy, we must first install it.
You can install the SymPy library on any computer with Python (version 2.6 and above).
Also read: Method sympy.combsimp() in Python
Installing SymPy through Anaconda
Anaconda is a free, open-source distribution of Python that comes with a Python interpreter and various tools and packages related to the same.
It is one of the most commonly used platforms for Python programming. Let us now look into how to install SymPy through it!
Installing Anaconda into your system will automatically install the SymPy library along with other major libraries and packages.
However, if you are not using the anaconda distribution of Python, you can install SymPy by typing the following command on Anaconda Prompt:
conda install sympy
You can also install it using pip as follows:
pip install sympy
To cross-check if SymPy has been successfully installed, you can run the following commands:
import sympy sympy.__version__
If you already have the SymPy package but are looking to update it, then use the following command on Anaconda Prompt:
conda update sympy
Using Git – Install SymPy in Python
If you are a GitHub contributor interested to improve the SymPy library or want to stay up to date with updates, you can install SymPy through git as follows:
Go to the command line (CMD) and execute the command below:
git clone https://github.com/sympy/sympy.git
If you have got this done before and are looking to update your SymPy version, execute the following command:
git pull origin master
There is another command that allows you to install SymPy and yet use the git version.
python setupegg.py develop
- No matter the way through which you install SymPy, it is important to verify that your installation was successful. You can do this by running any simple code that involves SymPy.
from sympy import * x=7 sqrt(x)
- If you have installed SymPy through Anaconda, it will usually contain the mpmath library in the background. This supports SymPy in various numerical evaluations.
However, if that is not the case, do install mpmath by using either of the following two commands:
conda install mpmath
pip install mpmath
- You can also directly download SymPy through its source code by visiting https://github.com/sympy/sympy/releases
Leave a Reply