I installed the Python scipy stack using the following command taken from here

sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose

However, I can import sympy only in Python 2.7.6 which is the default Python version when I type in python in the terminal. When I start Python 3.4.0 by typing in python3, the import sympy statement throws the error

>>> import sympy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'sympy'

How do I fix this problem?

3 Answers 3


You can use pip3 (which is just normal pip but in system's Python3 packages). Normally I would suggest avoiding using pip for installing stuff globally but given there are no packages for this that could overwrite the files, there's nothing to lose.

It's quick and simple:

sudo apt-get install python3-pip
sudo pip3 install sympy
  • Why using pip to install packages globally should be avoided?
    – ajay
    Jan 21, 2015 at 12:14
  • 2
    For example if you have the python-requests package installed and then sudo pip install requests, it'll overwrite files that apt installed and then if apt updates, it'll overwrite those files and it turns into a big mushy mess. The two systems will likely be using different versions of the Requests library too. If you need your own Python environment (which you might, I do for Django development) use virtualenv.
    – Oli
    Jan 21, 2015 at 12:21
  • 1
    ... Or python3 -m venv for Python 3
    – Oli
    Dec 14, 2015 at 15:11

In Ubuntu 16.04 and later, Sympy Computer Algebra System in Python can be installed from the default Ubuntu repositories. Open the terminal and type:

sudo apt install python3-sympy  

To install Sympy for Python 2.x in Ubuntu 18.04 and earlier run:

sudo apt install python-sympy

There's a backports and a nightly PPA with versions for all recent Ubuntu releases. Simply go

sudo add-apt-repository ppa:nschloe/sympy-backports
sudo apt update
sudo apt install python3-sympy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.