user2452046
user2452046

Reputation: 15

Import does work in console but not script

I try to run Sympy, a library for Python but I got a problem...

When I import Sympy in the console

>>> import os
>>> from os import chdir
>>> chdir("C:/sympy-0.7.2")
>>> import sympy
>>>

It works, but if I make a script with this content...ERROR! Why ?

This error

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

Upvotes: 1

Views: 2976

Answers (2)

Mike M&#252;ller
Mike M&#252;ller

Reputation: 85442

Run the script from C:/sympy-0.7.2.

Better yet, install sympy. It will go into your site-packages directory and will be available from anywhere. Going into C:/sympy-0.7.2 and typing python setup.py install should work.

Upvotes: 1

abhishekgarg
abhishekgarg

Reputation: 1473

try this..

import sys
sys.path.append("C:/sympy-0.7.2")
import sympy

Upvotes: 7

Related Questions