ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 24 Jun 2017 16:29:30 +0200Error importing scipy for SAGE notebookhttps://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/The following code -which I got as an example off the web- works fine in a SageCell but doesn't run in my Sage notebook.
Here is the code. Help or hints please!!!
mydata = [[1,3],[2,7],[3,13],[4,24]]
var('a,b')
mymodel(x) = a*x + b
myfit = find_fit(mydata,mymodel,solution_dict=True)
points(mydata,color='purple') + plot(
mymodel(
a=myfit[a],
b=myfit[b]
),
(x,0,4,),
color='red'
)
Here is the error message:
Traceback (most recent call last): a=myfit[a],
File "", line 1, in <module>
File "/private/var/folders/18/gmqqrhkd1wb4l1pv6sldfr5r0000gp/T/tmpSL56oE/___code___.py", line 6, in <module>
myfit = find_fit(mydata,mymodel,solution_dict=True)
File "sage/misc/lazy_import.pyx", line 386, in sage.misc.lazy_import.LazyImport.__call__ (/Applications/SageMath-7.2.app/Contents/Resources/sage/src/build/cythonized/sage/misc/lazy_import.c:3627)
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 697, in find_fit
from scipy.optimize import leastsq
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/scipy/__init__.py", line 103, in <module>
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
Thanks very much!!!!Sat, 11 Feb 2017 23:03:29 +0100https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/Comment by kcrisman for <p>The following code -which I got as an example off the web- works fine in a SageCell but doesn't run in my Sage notebook.
Here is the code. Help or hints please!!!</p>
<pre><code>mydata = [[1,3],[2,7],[3,13],[4,24]]
var('a,b')
mymodel(x) = a*x + b
myfit = find_fit(mydata,mymodel,solution_dict=True)
points(mydata,color='purple') + plot(
mymodel(
a=myfit[a],
b=myfit[b]
),
(x,0,4,),
color='red'
)
Here is the error message:
Traceback (most recent call last): a=myfit[a],
File "", line 1, in <module>
File "/private/var/folders/18/gmqqrhkd1wb4l1pv6sldfr5r0000gp/T/tmpSL56oE/___code___.py", line 6, in <module>
myfit = find_fit(mydata,mymodel,solution_dict=True)
File "sage/misc/lazy_import.pyx", line 386, in sage.misc.lazy_import.LazyImport.__call__ (/Applications/SageMath-7.2.app/Contents/Resources/sage/src/build/cythonized/sage/misc/lazy_import.c:3627)
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 697, in find_fit
from scipy.optimize import leastsq
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/scipy/__init__.py", line 103, in <module>
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
</code></pre>
<p>Thanks very much!!!!</p>
https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=36575#post-id-36575This error is really weird. Where and how exactly are you launching the Sage Mac app?Sun, 12 Feb 2017 00:13:03 +0100https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=36575#post-id-36575Comment by al for <p>The following code -which I got as an example off the web- works fine in a SageCell but doesn't run in my Sage notebook.
Here is the code. Help or hints please!!!</p>
<pre><code>mydata = [[1,3],[2,7],[3,13],[4,24]]
var('a,b')
mymodel(x) = a*x + b
myfit = find_fit(mydata,mymodel,solution_dict=True)
points(mydata,color='purple') + plot(
mymodel(
a=myfit[a],
b=myfit[b]
),
(x,0,4,),
color='red'
)
Here is the error message:
Traceback (most recent call last): a=myfit[a],
File "", line 1, in <module>
File "/private/var/folders/18/gmqqrhkd1wb4l1pv6sldfr5r0000gp/T/tmpSL56oE/___code___.py", line 6, in <module>
myfit = find_fit(mydata,mymodel,solution_dict=True)
File "sage/misc/lazy_import.pyx", line 386, in sage.misc.lazy_import.LazyImport.__call__ (/Applications/SageMath-7.2.app/Contents/Resources/sage/src/build/cythonized/sage/misc/lazy_import.c:3627)
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 697, in find_fit
from scipy.optimize import leastsq
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/scipy/__init__.py", line 103, in <module>
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
</code></pre>
<p>Thanks very much!!!!</p>
https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=36582#post-id-36582Thanks for asking.
I have SAGE 7.2 installed on my mac with OSX 10.10.5. It opens in the Firefox browser and runs fine-
I have quite a few worksheets- but this is the fist time I tried to use the command find_fit
which is part of scipy. It seems scipy is included in the SAGE I installed, yet i get this error.
I checked, and the code runs fine in the SAGE cell and no doubt (haven't tried it ) in the Cloud. I would rather have it running in the notebook so I can easily save a pdf of the output and save the code.Sun, 12 Feb 2017 10:11:29 +0100https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=36582#post-id-36582Comment by kcrisman for <p>The following code -which I got as an example off the web- works fine in a SageCell but doesn't run in my Sage notebook.
Here is the code. Help or hints please!!!</p>
<pre><code>mydata = [[1,3],[2,7],[3,13],[4,24]]
var('a,b')
mymodel(x) = a*x + b
myfit = find_fit(mydata,mymodel,solution_dict=True)
points(mydata,color='purple') + plot(
mymodel(
a=myfit[a],
b=myfit[b]
),
(x,0,4,),
color='red'
)
Here is the error message:
Traceback (most recent call last): a=myfit[a],
File "", line 1, in <module>
File "/private/var/folders/18/gmqqrhkd1wb4l1pv6sldfr5r0000gp/T/tmpSL56oE/___code___.py", line 6, in <module>
myfit = find_fit(mydata,mymodel,solution_dict=True)
File "sage/misc/lazy_import.pyx", line 386, in sage.misc.lazy_import.LazyImport.__call__ (/Applications/SageMath-7.2.app/Contents/Resources/sage/src/build/cythonized/sage/misc/lazy_import.c:3627)
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 697, in find_fit
from scipy.optimize import leastsq
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/scipy/__init__.py", line 103, in <module>
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
</code></pre>
<p>Thanks very much!!!!</p>
https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=36602#post-id-36602Huh, that will take a little time to look into, then, because it seems to be very specific to your setup. What happens if you just do "import scipy" or "import numpy" in a new worksheet? The same thing?Mon, 13 Feb 2017 15:43:31 +0100https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=36602#post-id-36602Comment by al for <p>The following code -which I got as an example off the web- works fine in a SageCell but doesn't run in my Sage notebook.
Here is the code. Help or hints please!!!</p>
<pre><code>mydata = [[1,3],[2,7],[3,13],[4,24]]
var('a,b')
mymodel(x) = a*x + b
myfit = find_fit(mydata,mymodel,solution_dict=True)
points(mydata,color='purple') + plot(
mymodel(
a=myfit[a],
b=myfit[b]
),
(x,0,4,),
color='red'
)
Here is the error message:
Traceback (most recent call last): a=myfit[a],
File "", line 1, in <module>
File "/private/var/folders/18/gmqqrhkd1wb4l1pv6sldfr5r0000gp/T/tmpSL56oE/___code___.py", line 6, in <module>
myfit = find_fit(mydata,mymodel,solution_dict=True)
File "sage/misc/lazy_import.pyx", line 386, in sage.misc.lazy_import.LazyImport.__call__ (/Applications/SageMath-7.2.app/Contents/Resources/sage/src/build/cythonized/sage/misc/lazy_import.c:3627)
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 697, in find_fit
from scipy.optimize import leastsq
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/scipy/__init__.py", line 103, in <module>
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
</code></pre>
<p>Thanks very much!!!!</p>
https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=38075#post-id-38075Hi kcrisman- I finally got back to this issue and am trying to resolve it. The problem is that for some reason
I can't get 3d graphics to work in my sage notebook. I thought scipy would be part of the sagemath package 7.2, so am surprised it may need to be installed. In any case, just saw your suggestion of trying to do "import scipy" so I added it to a program found on the web, which runs fine in sage cell. Here is the result.
import scipy
x, y = var('x y')
W = plot3d(sin(pi*((x)^2+(y)^2))/2,(x,-1,1),(y,-1,1), frame=False, color='purple', opacity=0.8)
S = sphere((0,0,0),size=0.3, color='red', aspect_ratio=[1,1,1])
show(W + S, figsize=8)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_17.py", line 10, in <module>
exec compile(u'open("_Sat, 24 Jun 2017 07:30:14 +0200https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=38075#post-id-38075Comment by al for <p>The following code -which I got as an example off the web- works fine in a SageCell but doesn't run in my Sage notebook.
Here is the code. Help or hints please!!!</p>
<pre><code>mydata = [[1,3],[2,7],[3,13],[4,24]]
var('a,b')
mymodel(x) = a*x + b
myfit = find_fit(mydata,mymodel,solution_dict=True)
points(mydata,color='purple') + plot(
mymodel(
a=myfit[a],
b=myfit[b]
),
(x,0,4,),
color='red'
)
Here is the error message:
Traceback (most recent call last): a=myfit[a],
File "", line 1, in <module>
File "/private/var/folders/18/gmqqrhkd1wb4l1pv6sldfr5r0000gp/T/tmpSL56oE/___code___.py", line 6, in <module>
myfit = find_fit(mydata,mymodel,solution_dict=True)
File "sage/misc/lazy_import.pyx", line 386, in sage.misc.lazy_import.LazyImport.__call__ (/Applications/SageMath-7.2.app/Contents/Resources/sage/src/build/cythonized/sage/misc/lazy_import.c:3627)
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 697, in find_fit
from scipy.optimize import leastsq
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/scipy/__init__.py", line 103, in <module>
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
</code></pre>
<p>Thanks very much!!!!</p>
https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=38076#post-id-38076Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_17.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("aW1wb3J0IHNjaXB5CngsIHkgPSB2YXIoJ3ggeScpClcgPSBwbG90M2Qoc2luKHBpKigoeCleMisoeSleMikpLzIsKHgsLTEsMSksKHksLTEsMSksIGZyYW1lPUZhbHNlLCBjb2xvcj0ncHVycGxlJywgb3BhY2l0eT0wLjgpClMgPSBzcGhlcmUoKDAsMCwwKSxzaXplPTAuMywgY29sb3I9J3JlZCcsIGFzcGVjdF9yYXRpbz1bMSwxLDFdKQpzaG93KFcgKyBTLCBmaWdzaXplPTgp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>Sat, 24 Jun 2017 07:32:42 +0200https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=38076#post-id-38076Comment by al for <p>The following code -which I got as an example off the web- works fine in a SageCell but doesn't run in my Sage notebook.
Here is the code. Help or hints please!!!</p>
<pre><code>mydata = [[1,3],[2,7],[3,13],[4,24]]
var('a,b')
mymodel(x) = a*x + b
myfit = find_fit(mydata,mymodel,solution_dict=True)
points(mydata,color='purple') + plot(
mymodel(
a=myfit[a],
b=myfit[b]
),
(x,0,4,),
color='red'
)
Here is the error message:
Traceback (most recent call last): a=myfit[a],
File "", line 1, in <module>
File "/private/var/folders/18/gmqqrhkd1wb4l1pv6sldfr5r0000gp/T/tmpSL56oE/___code___.py", line 6, in <module>
myfit = find_fit(mydata,mymodel,solution_dict=True)
File "sage/misc/lazy_import.pyx", line 386, in sage.misc.lazy_import.LazyImport.__call__ (/Applications/SageMath-7.2.app/Contents/Resources/sage/src/build/cythonized/sage/misc/lazy_import.c:3627)
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 697, in find_fit
from scipy.optimize import leastsq
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/scipy/__init__.py", line 103, in <module>
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
</code></pre>
<p>Thanks very much!!!!</p>
https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=38077#post-id-38077File "/private/var/folders/18/gmqqrhkd1wb4l1pv6sldfr5r0000gp/T/tmp9VOZ6s/___code___.py", line 3, in <module>
import scipy
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/scipy/__init__.py", line 103, in <module>
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
Any ideas?? Thanks!Sat, 24 Jun 2017 07:33:15 +0200https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=38077#post-id-38077Comment by al for <p>The following code -which I got as an example off the web- works fine in a SageCell but doesn't run in my Sage notebook.
Here is the code. Help or hints please!!!</p>
<pre><code>mydata = [[1,3],[2,7],[3,13],[4,24]]
var('a,b')
mymodel(x) = a*x + b
myfit = find_fit(mydata,mymodel,solution_dict=True)
points(mydata,color='purple') + plot(
mymodel(
a=myfit[a],
b=myfit[b]
),
(x,0,4,),
color='red'
)
Here is the error message:
Traceback (most recent call last): a=myfit[a],
File "", line 1, in <module>
File "/private/var/folders/18/gmqqrhkd1wb4l1pv6sldfr5r0000gp/T/tmpSL56oE/___code___.py", line 6, in <module>
myfit = find_fit(mydata,mymodel,solution_dict=True)
File "sage/misc/lazy_import.pyx", line 386, in sage.misc.lazy_import.LazyImport.__call__ (/Applications/SageMath-7.2.app/Contents/Resources/sage/src/build/cythonized/sage/misc/lazy_import.c:3627)
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 697, in find_fit
from scipy.optimize import leastsq
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/scipy/__init__.py", line 103, in <module>
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
</code></pre>
<p>Thanks very much!!!!</p>
https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=38078#post-id-38078PS I just tried changing the line "import scipy" to "import numpy"
and get a long error message finishing the same way, with:
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.Sat, 24 Jun 2017 07:34:52 +0200https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=38078#post-id-38078Comment by kcrisman for <p>The following code -which I got as an example off the web- works fine in a SageCell but doesn't run in my Sage notebook.
Here is the code. Help or hints please!!!</p>
<pre><code>mydata = [[1,3],[2,7],[3,13],[4,24]]
var('a,b')
mymodel(x) = a*x + b
myfit = find_fit(mydata,mymodel,solution_dict=True)
points(mydata,color='purple') + plot(
mymodel(
a=myfit[a],
b=myfit[b]
),
(x,0,4,),
color='red'
)
Here is the error message:
Traceback (most recent call last): a=myfit[a],
File "", line 1, in <module>
File "/private/var/folders/18/gmqqrhkd1wb4l1pv6sldfr5r0000gp/T/tmpSL56oE/___code___.py", line 6, in <module>
myfit = find_fit(mydata,mymodel,solution_dict=True)
File "sage/misc/lazy_import.pyx", line 386, in sage.misc.lazy_import.LazyImport.__call__ (/Applications/SageMath-7.2.app/Contents/Resources/sage/src/build/cythonized/sage/misc/lazy_import.c:3627)
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/numerical/optimize.py", line 697, in find_fit
from scipy.optimize import leastsq
File "/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/scipy/__init__.py", line 103, in <module>
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
</code></pre>
<p>Thanks very much!!!!</p>
https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=38081#post-id-38081I think it would be worth trying the same command from the command line so we can see a full traceback. This may also be better dealt with on sage-support@googlegroups.com since this venue isn't exactly easy for debugging. My guess (only a guess) is that your Sage download expects different system libraries than you have on that particular Mac; what exact version did you download?Sat, 24 Jun 2017 16:29:30 +0200https://ask.sagemath.org/question/36574/error-importing-scipy-for-sage-notebook/?comment=38081#post-id-38081