Installation#
The SymPy CAS can be installed on virtually any computer with Python. SymPy does require mpmath Python library to be installed first. The recommended method of installation is through Anaconda, which includes mpmath, as well as several other useful libraries. Alternatively, some Linux distributions have SymPy packages available.
SymPy officially supports Python 3.8, 3.9, 3.10, and PyPy.
Anaconda#
Anaconda is a free Python distribution from Continuum Analytics that includes SymPy, Matplotlib, IPython, NumPy, and many more useful packages for scientific computing. This is recommended because many nice features of SymPy are only enabled when certain libraries are installed. For example, without Matplotlib, only simple text-based plotting is enabled. With the IPython notebook or qtconsole, you can get nicer \(\mathrm<\LaTeX>\) printing by running init_printing() .
If you already have Anaconda and want to update SymPy to the latest version, use:
If you wish to contribute to SymPy or like to get the latest updates as they come, install SymPy from git. To download the repository, execute the following from the command line:
To update to the latest version, go into your repository and execute:
If you want to install SymPy, but still want to use the git version, you can run from your repository:
This will cause the installed version to always point to the version in the git directory.
Other Methods#
You may also install SymPy using pip or from source. In addition, most Linux and Python distributions have some SymPy version available to install using their package manager. Here is a list of several such Python distributions:
Run SymPy#
After installation, it is best to verify that your freshly-installed SymPy works. To do this, start up Python and import the SymPy libraries:
From here, execute some simple SymPy statements like the ones below:
For a starter guide on using SymPy effectively, refer to the Introductory Tutorial .
mpmath#
Versions of SymPy prior to 1.0 included mpmath, but it now depends on it as an external dependency. If you installed SymPy with Anaconda, it will already include mpmath. Use:
to ensure that it is installed.
If you do not wish to use Anaconda, you can use pip install mpmath .
If you use mpmath via sympy.mpmath in your code, you will need to change this to use just mpmath . If you depend on code that does this that you cannot easily change, you can work around it by doing:
before the code that imports sympy.mpmath . It is recommended to change code that uses sympy.mpmath to use mpmath directly wherever possible.
Questions#
If you have a question about installation or SymPy in general, feel free to visit our chat on Gitter. In addition, our mailing list is an excellent source of community support.
If you think there’s a bug or you would like to request a feature, please open an issue ticket.
SymPy
And many more people helped on the SymPy mailing list, reported bugs, helped organize SymPy’s participation in the Google Summer of Code, the Google Highly Open Participation Contest, Google Code-In, wrote and blogged about SymPy.
License: New BSD License (see the LICENSE file for details) covers all files in the sympy repository unless stated otherwise.
We have a community chat at Gitter. Feel free to ask us anything there. We have a very welcoming and helpful community.
Download
The recommended installation method is through Anaconda, https://www.anaconda.com/products/distribution
You can also get the latest version of SymPy from https://pypi.python.org/pypi/sympy/
To get the git version do
Documentation and Usage
For in-depth instructions on installation and building the documentation, see the SymPy Documentation Style Guide.
Everything is at:
You can generate everything at the above site in your local copy of SymPy by:
Then the docs will be in _build/html . If you don’t want to read that, here is a short usage:
From this directory, start Python and:
SymPy also comes with a console that is a simple wrapper around the classic python console (or IPython when available) that loads the SymPy namespace and executes some common commands for you.
To start it, issue:
from this directory, if SymPy is not installed or simply:
if SymPy is installed.
Installation
SymPy has a hard dependency on the mpmath library (version >= 0.19). You should install it first, please refer to the mpmath installation guide:
To install SymPy using PyPI, run the following command:
To install SymPy using Anaconda, run the following command:
To install SymPy from GitHub source, first clone SymPy using git :
Then, in the sympy repository that you cloned, simply run:
Contributing
We welcome contributions from anyone, even if you are new to open source. Please read our Introduction to Contributing page and the SymPy Documentation Style Guide. If you are new and looking for some way to contribute, a good place to start is to look at the issues tagged Easy to Fix.
Please note that all participants in this project are expected to follow our Code of Conduct. By participating in this project you agree to abide by its terms. See CODE_OF_CONDUCT.md.
Tests
To execute all tests, run:
in the current directory.
For the more fine-grained running of tests or doctests, use bin/test or respectively bin/doctest . The master branch is automatically tested by GitHub Actions.
To test pull requests, use sympy-bot.
Regenerate Experimental LaTeX Parser/Lexer
The parser and lexer were generated with the ANTLR4 toolchain in sympy/parsing/latex/_antlr and checked into the repo. Presently, most users should not need to regenerate these files, but if you plan to work on this feature, you will need the antlr4 command-line tool (and you must ensure that it is in your PATH ). One way to get it is:
Alternatively, follow the instructions on the ANTLR website and download the antlr-4.11.1-complete.jar . Then export the CLASSPATH as instructed and instead of creating antlr4 as an alias, make it an executable file with the following contents:
After making changes to sympy/parsing/latex/LaTeX.g4 , run:
Clean
To clean everything (thus getting the same tree as in the repository):
which will clear everything ignored by .gitignore , and:
to clear all untracked files. You can revert the most recent changes in git with:
WARNING: The above commands will all clear changes you may have made, and you will lose them forever. Be sure to check things with git status , git diff , git clean -Xn , and git clean -n before doing any of those.
Our issue tracker is at https://github.com/sympy/sympy/issues. Please report any bugs that you find. Or, even better, fork the repository on GitHub and create a pull request. We welcome all changes, big or small, and we will help you make the pull request if you are new to git (just ask on our mailing list or Gitter Channel). If you further have any queries, you can find answers on Stack Overflow using the sympy tag.
Brief History
SymPy was started by Ondřej Čertík in 2005, he wrote some code during the summer, then he wrote some more code during summer 2006. In February 2007, Fabian Pedregosa joined the project and helped fix many things, contributed documentation, and made it alive again. 5 students (Mateusz Paprocki, Brian Jorgensen, Jason Gedge, Robert Schwarz, and Chris Wu) improved SymPy incredibly during summer 2007 as part of the Google Summer of Code. Pearu Peterson joined the development during the summer 2007 and he has made SymPy much more competitive by rewriting the core from scratch, which has made it from 10x to 100x faster. Jurjen N.E. Bos has contributed pretty-printing and other patches. Fredrik Johansson has written mpmath and contributed a lot of patches.
SymPy has participated in every Google Summer of Code since 2007. You can see https://github.com/sympy/sympy/wiki#google-summer-of-code for full details. Each year has improved SymPy by bounds. Most of SymPy’s development has come from Google Summer of Code students.
In 2011, Ondřej Čertík stepped down as lead developer, with Aaron Meurer, who also started as a Google Summer of Code student, taking his place. Ondřej Čertík is still active in the community but is too busy with work and family to play a lead development role.
Since then, a lot more people have joined the development and some people have also left. You can see the full list in doc/src/aboutus.rst, or online at:
The git history goes back to 2007 when development moved from svn to hg. To see the history before that point, look at https://github.com/sympy/sympy-old.
You can use git to see the biggest developers. The command:
will show each developer, sorted by commits to the project. The command:
will show the top developers from the last year.
Citation
To cite SymPy in publications use
Meurer A, Smith CP, Paprocki M, Čertík O, Kirpichev SB, Rocklin M, Kumar A, Ivanov S, Moore JK, Singh S, Rathnayake T, Vig S, Granger BE, Muller RP, Bonazzi F, Gupta H, Vats S, Johansson F, Pedregosa F, Curry MJ, Terrel AR, Roučka Š, Saboo A, Fernando I, Kulal S, Cimrman R, Scopatz A. (2017) SymPy: symbolic computing in Python. PeerJ Computer Science 3:e103 https://doi.org/10.7717/peerj-cs.103
A BibTeX entry for LaTeX users is
SymPy is BSD licensed, so you are free to use it whatever you like, be it academic, commercial, creating forks or derivatives, as long as you copy the BSD statement if you redistribute it (see the LICENSE file for details). That said, although not required by the SymPy license, if it is convenient for you, please cite SymPy when using it in your work and also consider contributing all your changes back, so that we can incorporate it and all of us will benefit in the end.
Installation¶
The SymPy CAS can be installed on virtually any computer with Python 2.6 or above. SymPy does not require any special Python modules: let us know if you have any problems with SymPy on a standard Python install. The current recommended method of installation is directly from the source files. Alternatively, executables are available for Windows, and some Linux distributions have SymPy packages available.
SymPy officially supports Python 2.6, 2.7, 3.2, 3.3, 3.4, and PyPy.
Source¶
SymPy currently recommends that users install directly from the source files. You will first have to download the source files via the archive. Download the latest release (tar.gz) from the downloads site and open it with your operating system’s standard decompression utility.
After the download is complete, you should have a folder called “sympy”. From your favorite command line terminal, change directory into that folder and execute the following:
Alternatively, if you don’t want to install the package onto your computer, you may run SymPy with the “isympy” console (which automatically imports SymPy packages and defines common symbols) by executing within the “sympy” folder:
You may now run SymPy statements directly within the Python shell:
If you are a developer or like to get the latest updates as they come, be sure to install from git. To download the repository, execute the following from the command line:
Then, execute either the \(setup.py\) or the \(bin/isympy\) scripts as demonstrated above.
To update to the latest version, go into your repository and execute:
If you want to install SymPy, but still want to use the git version, you can run from your repository:
This will cause the installed version to always point to the version in the git directory.
Anaconda¶
Although SymPy does not have any hard dependencies, many nice features are only enabled when certain libraries are installed. For example, without Matplotlib, only simple text-based plotting is enabled. With the IPython notebook or qtconsole, you can get nicer \(\LaTeX\) printing by running init_printing() . An easy way to get all these libraries in addition to SymPy is to install Anaconda, which is a free Python distribution from Continuum Analytics that includes SymPy, Matplotlib, IPython, NumPy, and many more useful packages for scientific computing.
Other Methods¶
An installation executable (.exe) is available for Windows users at the downloads site. In addition, various Linux distributions have SymPy available as a package. Others are strongly encouraged to download from source (details above).
Run SymPy¶
After installation, it is best to verify that your freshly-installed SymPy works. To do this, start up Python and import the SymPy libraries:
From here, execute some simple SymPy statements like the ones below:
For a starter guide on using SymPy effectively, refer to the SymPy Tutorial.
Questions¶
If you have a question about installation or SymPy in general, feel free to visit our chat on Gitter. In addition, our mailing list is an excellent source of community support.
If you think there’s a bug or you would like to request a feature, please open an issue ticket.
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).
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:
You can also install it using pip as follows:
To cross-check if SymPy has been successfully installed, you can run the following commands:
If you already have the SymPy package but are looking to update it, then use the following command on Anaconda Prompt:
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:
If you have got this done before and are looking to update your SymPy version, execute the following command:
There is another command that allows you to install SymPy and yet use the git version.