Sympy and mpmath imported but still ImportError

1,717 views
Skip to first unread message

Alexander Tille

unread,
Nov 8, 2016, 9:52:40 AM11/8/16
to sympy
Hi guys,
I don't understand the relationship of sympy and mpmath.
As I followed the instructions of http://docs.sympy.org/latest/install.html#mpmath
I installed mpmath and sympy as you can see in the following lines.

$ pip install sympy
Collecting sympy
Requirement already satisfied: mpmath>=0.19 in /home/atille/.anaconda2/lib/python2.7/site-packages (from sympy)
Installing collected packages: sympy
Successfully installed sympy-1.0


my code includes the following lines

import sys
import mpmath
from sympy import *
from sympy import solve
from sympy import init_printing

but results in this error message

Traceback (most recent call last):
File "./algebraic_calculation_model_6_rescaled.py", line 4, in <module>
import sympy.mpmath
File "/usr/lib/python2.7/dist-packages/sympy/__init__.py", line 20, in <module>
raise ImportError("SymPy now depends on mpmath as an external library. "
ImportError: SymPy now depends on mpmath as an external library. See http://docs.sympy.org/latest/install.html#mpmath for more information.

Can you explain my mistake?

Thank you in advance.

Björn Dahlgren

unread,
Nov 8, 2016, 1:40:56 PM11/8/16
to sympy


On Tuesday, 8 November 2016 15:52:40 UTC+1, Alexander Tille wrote:

Hi,
 
Traceback (most recent call last):
File "./algebraic_calculation_model_6_rescaled.py", line 4, in <module>
import sympy.mpmath
/.../
Can you explain my mistake?

If you change that line to "import mpmath" (and change any code referencing it accordingly) it should be fine.

Best regards,
Björn

Alexander Tille

unread,
Nov 9, 2016, 5:59:12 AM11/9/16
to sympy
Hi,
I checked also this solution.


Traceback (most recent call last):
  File "./algebraic_calculation_model_9_rescaled_D-I-with_rd.py", line 4, in <module>
    import mpmath
ImportError: No module named mpmath

I tried to add the anaconda directory to the python path but it doesn't work because I get the same error message
     PYTHONPATH="${PYTHONPATH}:/home/atille/.anaconda2/lib/python2.7/site-packages"
     export PYTHONPATH


It works fine if I copy the mpmath library from my anaconda directory into the directory where I execute the code.
In this case I comment the import mpmath command.
But this soultion is really ugly.

Aaron Meurer

unread,
Nov 9, 2016, 2:30:34 PM11/9/16
to sy...@googlegroups.com
If you are using the Anaconda Python, neither of these should be necessary.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/eab0b547-26bb-4aab-9c11-ba38006b19e6%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Alexander Tille

unread,
Nov 10, 2016, 3:01:28 AM11/10/16
to sympy
Ok! Thank you for this answer.

I still used the standard python interpreter.
I changed it to
#!~/.anaconda2/bin/python
and it works.

Thank you for your explanations.

Alex
Reply all
Reply to author
Forward
0 new messages