Execute .py file -> not recognizing Symbol, when file isn't inside of sympy dir

37 views
Skip to first unread message

Michał Pawłowski

unread,
Feb 10, 2021, 3:47:19 PM2/10/21
to sympy
Hi.

I have such problem.

I've created py file:

#!/usr/bin/python3

from sympy import *
x = Symbol('x')
print(expand(sin(x)*(x-1)*(x+1)))

When it is inside of SymPy lib dir, it returns correct result in console.
But, when I put it not inside the lib dir, it tells me, that:

NameError: name 'Symbol' is not defined

How can I fix it, to be able to execute this file from anywhere in my directory tree?

Thanks
Mike

Oscar Benjamin

unread,
Feb 10, 2021, 3:53:02 PM2/10/21
to sympy
That should work fine. Have you actually installed sympy or have you
just downloaded the code?

By any chance have you created a file somewhere called "sympy.py"
because that would be picked up by "import sympy".

--
Oscar
Message has been deleted

Michał Pawłowski

unread,
Feb 10, 2021, 4:03:48 PM2/10/21
to sympy
Thanks.

I used git clone ... thats all 

Oscar Benjamin

unread,
Feb 10, 2021, 4:14:07 PM2/10/21
to sympy
Do you particularly want to use the master version of sympy from git?

It's usually better to use the latest release (currently 1.7.1) unless
you are planning to work on making changes to sympy itself.

You can install the latest release by running e.g "pip install sympy"
(or "conda install sympy" if you are using Anaconda).

If you do want to install the master version of sympy then you need to
run "python setup.py install" (after "git clone").

Oscar
> --
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/sympy/96786754-3025-4b31-886d-4ee4a54e38d5n%40googlegroups.com.

Michał Pawłowski

unread,
Feb 10, 2021, 4:25:09 PM2/10/21
to sympy
Thank you so much, it works great now! :)
I haven't installed it. I have newest version I used to used git pull ..

Thank U
Mike

środa, 10 lutego 2021 o 22:14:07 UTC+1 Oscar napisał(a):
Do you particularly want to use the master version of sympy from git?

It's usually better to use the latest release (currently 1.7.1) unless
you are planning to work on making changes to sympy itself.

You can install the latest release by running e.g "pip install sympy"
(or "conda install sympy" if you are using Anaconda).

If you do want to install the master version of sympy then you need to
run "python setup.py install" (after "git clone").

Oscar

Reply all
Reply to author
Forward
0 new messages