Import newer version of built-in module
The current version of Pythonista (1.5) comes with Sympy 0.7.4.1, but I need version 0.7.5.
I have downloaded the newest version of the module using the script installsympy at https://gist.github.com/henryiii/9011826 and I can see a sympy folder in Pythonista.
How can I import the newest version?
"import sympy" imports the builtin version, and renaming the folder to something like sympy2 and then importing it gives me conflict errors.
What is the right way to do this? absolute_import?
If I try:
from . import sympy
Traceback (most recent call last): File "<string>", line 1, in <module> ValueError: Attempted relative import in non-package
sys.pathto out your new sympy folder at the start.
I think you can also use
I think it is also possible to manually set
__package__before doing the import the way your tried, but not sure.
Thanks for the reply JonB.
Using sys.path.append does not solve the problem.
Honestly I am a bit in the dark (i.e. am a complete newbie), so I run sys.path.append('.'), sys.path.append('..') and sys.path.append('sympy'), not knowing which one was the right one (and killing Pythonista each time to stay on the safe side).
In all cases,
import sympy sympy.__version__
What am I doing wrong?
I believe you want to insert at the top, not append at the end, so that it searches your new folder first. Be sure to restart pythinista before trying this (or possibly del(sys.modules[sympy]))
Ok, suppose you put sympy in the main pythonista directory, under newsympy.
So, you have a folder called newsympy/sympy, which contains the
Then, you would insert this top level path, at the start of sys.path, like this
Point to the path above the folder named sympy.
You should use
abspathwon't expand the tilde (
Thanks that worked!