No module named sympy

Hi i am learning linear algebra with python with Edx course. ( http://nbviewer.ipython.org/github/ULAFF/notebooks/tree/may-14-2014/ ).

In "02.4.2.10 Practice with matrix-vector multiplication" with the first field the code:

import generate_problems as gp
print("What is the result of the matrix vector product below?")

p = gp.Problem()

p.new_problem()

      

generate_problems is a module created by Professor Edx. However, I got an error importing sympy.

I got below error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-10-79d56e0988cb> in <module>()
----> 1 import generate_problems as gp
      2 print("What is the result of the matrix vector product below?")
      3 
      4 p = gp.Problem()
      5 

/Users/user/Desktop/Course/Python/ipython/notebooks-master/generate_problems.py in <module>()
      2 from numpy import matrix
      3 
----> 4 from sympy import init_printing, Matrix, MatMul, latex, Rational, zeros
      5 from IPython.display import Math
      6 

ImportError: No module named sympy

      

I downloaded and installed sympy and it works in a simplex directory in the terminal (Mac OS X yosemite) if I import. Can anyone help me?

+3


source to share


2 answers


Considering that you are new to Python, I would suggest that you install a distribution that already includes a full scientific python stack like WinPython or Anaconda . If it's definitely cute, after you can play online Sympy live . If you want to stick with your distribution try installing sympy with

pip install sympy

      



rather than loading it manually.

+5


source


you can also do this in jupyter notebook . Write this in a cell and run this cell:

!pip install --upgrade
!pip install sympy 
import sympy

      

If your kernel uses python3, use "pip3" instead. You may have to do Kernel-> Restart if it doesn't work right away.

If it still doesn't find the module because Jupyter doesn't download the correct folder where it is installed. then consider doing either



import sys
sys.path.append('my/path/to/module/folder') 
#the (successful) line "!pip install sympy " should tell you where this path is

      

or (on a bash terminal)

echo "PYTHONPATH=\"$PYTHONPATH:my/path/to/module/folder\"" >> ~/.bashrc
source ~/.bashrc
# then restart jupyter notebook 

      

0


source







All Articles