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.Mon, 23 May 2016 18:25:47 +0200Traceback errorhttps://ask.sagemath.org/question/33456/traceback-error/ Hello,
I am new to Sage Math and new to this forum. Basically, I have written code to generate a specific graph on 10 vertices from its adjacency matrix. I am receiving an error (pasted below), but when my advisor runs the same exact code on his machine, he does not receive an error. I do not know how to resolve this situation. I've pasted my code below, and the error that I receive follows. Any insight would be much appreciated, and let me know if you need more details (e.g., information about the machine I'm using, operating system, etc.).
sage: M = Matrix([(0,0,1,0,1,1,1,0,1,1), (0,0,0,1,1,1,0,1,1,1), \
(1,0,0,1,1,1,1,0,0,0), (0,1,1,0,1,1,0,1,0,0), (1,1,1,1,0,1,0,0,1,0), \
(1,1,1,1,1,0,0,0,0,1), (1,0,1,0,0,0,0,1,1,1), (0,1,0,1,0,0,1,0,1,1), \
(1,1,0,0,1,0,1,1,0,1), (1,1,0,0,0,1,1,1,1,0)])
sage: M
[0 0 1 0 1 1 1 0 1 1]
[0 0 0 1 1 1 0 1 1 1]
[1 0 0 1 1 1 1 0 0 0]
[0 1 1 0 1 1 0 1 0 0]
[1 1 1 1 0 1 0 0 1 0]
[1 1 1 1 1 0 0 0 0 1]
[1 0 1 0 0 0 0 1 1 1]
[0 1 0 1 0 0 1 0 1 1]
[1 1 0 0 1 0 1 1 0 1]
[1 1 0 0 0 1 1 1 1 0]
sage: G = Graph(M); G
Graph on 10 vertices
sage: G.plot().show()
Here is the error.
Traceback (most recent call last): [0 0 0 1 1 1 0 1 1 1]
File "", line 1, in <module>
File "/private/var/folders/sw/0pqlf1452k58z_jbk3_yv5m97h2tyd/T/tmpabbyzH/___code___.py", line 5
G = Graph(M); G
^
SyntaxError: invalid syntax
Thu, 19 May 2016 21:56:50 +0200https://ask.sagemath.org/question/33456/traceback-error/Comment by tmonteil for <p>Hello,</p>
<p>I am new to Sage Math and new to this forum. Basically, I have written code to generate a specific graph on 10 vertices from its adjacency matrix. I am receiving an error (pasted below), but when my advisor runs the same exact code on his machine, he does not receive an error. I do not know how to resolve this situation. I've pasted my code below, and the error that I receive follows. Any insight would be much appreciated, and let me know if you need more details (e.g., information about the machine I'm using, operating system, etc.).</p>
<pre><code>sage: M = Matrix([(0,0,1,0,1,1,1,0,1,1), (0,0,0,1,1,1,0,1,1,1), \
(1,0,0,1,1,1,1,0,0,0), (0,1,1,0,1,1,0,1,0,0), (1,1,1,1,0,1,0,0,1,0), \
(1,1,1,1,1,0,0,0,0,1), (1,0,1,0,0,0,0,1,1,1), (0,1,0,1,0,0,1,0,1,1), \
(1,1,0,0,1,0,1,1,0,1), (1,1,0,0,0,1,1,1,1,0)])
sage: M
[0 0 1 0 1 1 1 0 1 1]
[0 0 0 1 1 1 0 1 1 1]
[1 0 0 1 1 1 1 0 0 0]
[0 1 1 0 1 1 0 1 0 0]
[1 1 1 1 0 1 0 0 1 0]
[1 1 1 1 1 0 0 0 0 1]
[1 0 1 0 0 0 0 1 1 1]
[0 1 0 1 0 0 1 0 1 1]
[1 1 0 0 1 0 1 1 0 1]
[1 1 0 0 0 1 1 1 1 0]
sage: G = Graph(M); G
Graph on 10 vertices
sage: G.plot().show()
</code></pre>
<p>Here is the error.</p>
<pre><code>Traceback (most recent call last): [0 0 0 1 1 1 0 1 1 1]
File "", line 1, in <module>
File "/private/var/folders/sw/0pqlf1452k58z_jbk3_yv5m97h2tyd/T/tmpabbyzH/___code___.py", line 5
G = Graph(M); G
^
SyntaxError: invalid syntax
</code></pre>
https://ask.sagemath.org/question/33456/traceback-error/?comment=33467#post-id-33467Could you please give us some informations so that someone can try to reproduce your problem:
- which version of Sage did you use ?
- which OS ?
- did you install Sage from the binaries, and which ones ?
- did you compile Sage yourself ?
- which notebook did you use (Sage notebook or jupyter notebook) ?
- did you use the command line ?Fri, 20 May 2016 18:13:38 +0200https://ask.sagemath.org/question/33456/traceback-error/?comment=33467#post-id-33467Comment by FrédéricC for <p>Hello,</p>
<p>I am new to Sage Math and new to this forum. Basically, I have written code to generate a specific graph on 10 vertices from its adjacency matrix. I am receiving an error (pasted below), but when my advisor runs the same exact code on his machine, he does not receive an error. I do not know how to resolve this situation. I've pasted my code below, and the error that I receive follows. Any insight would be much appreciated, and let me know if you need more details (e.g., information about the machine I'm using, operating system, etc.).</p>
<pre><code>sage: M = Matrix([(0,0,1,0,1,1,1,0,1,1), (0,0,0,1,1,1,0,1,1,1), \
(1,0,0,1,1,1,1,0,0,0), (0,1,1,0,1,1,0,1,0,0), (1,1,1,1,0,1,0,0,1,0), \
(1,1,1,1,1,0,0,0,0,1), (1,0,1,0,0,0,0,1,1,1), (0,1,0,1,0,0,1,0,1,1), \
(1,1,0,0,1,0,1,1,0,1), (1,1,0,0,0,1,1,1,1,0)])
sage: M
[0 0 1 0 1 1 1 0 1 1]
[0 0 0 1 1 1 0 1 1 1]
[1 0 0 1 1 1 1 0 0 0]
[0 1 1 0 1 1 0 1 0 0]
[1 1 1 1 0 1 0 0 1 0]
[1 1 1 1 1 0 0 0 0 1]
[1 0 1 0 0 0 0 1 1 1]
[0 1 0 1 0 0 1 0 1 1]
[1 1 0 0 1 0 1 1 0 1]
[1 1 0 0 0 1 1 1 1 0]
sage: G = Graph(M); G
Graph on 10 vertices
sage: G.plot().show()
</code></pre>
<p>Here is the error.</p>
<pre><code>Traceback (most recent call last): [0 0 0 1 1 1 0 1 1 1]
File "", line 1, in <module>
File "/private/var/folders/sw/0pqlf1452k58z_jbk3_yv5m97h2tyd/T/tmpabbyzH/___code___.py", line 5
G = Graph(M); G
^
SyntaxError: invalid syntax
</code></pre>
https://ask.sagemath.org/question/33456/traceback-error/?comment=33468#post-id-33468The first line of the traceback looks strange. It contains a line of the result of printing the matrix M. Did you copy paste the output of `sage: M` ?Fri, 20 May 2016 19:07:39 +0200https://ask.sagemath.org/question/33456/traceback-error/?comment=33468#post-id-33468Comment by JEA for <p>Hello,</p>
<p>I am new to Sage Math and new to this forum. Basically, I have written code to generate a specific graph on 10 vertices from its adjacency matrix. I am receiving an error (pasted below), but when my advisor runs the same exact code on his machine, he does not receive an error. I do not know how to resolve this situation. I've pasted my code below, and the error that I receive follows. Any insight would be much appreciated, and let me know if you need more details (e.g., information about the machine I'm using, operating system, etc.).</p>
<pre><code>sage: M = Matrix([(0,0,1,0,1,1,1,0,1,1), (0,0,0,1,1,1,0,1,1,1), \
(1,0,0,1,1,1,1,0,0,0), (0,1,1,0,1,1,0,1,0,0), (1,1,1,1,0,1,0,0,1,0), \
(1,1,1,1,1,0,0,0,0,1), (1,0,1,0,0,0,0,1,1,1), (0,1,0,1,0,0,1,0,1,1), \
(1,1,0,0,1,0,1,1,0,1), (1,1,0,0,0,1,1,1,1,0)])
sage: M
[0 0 1 0 1 1 1 0 1 1]
[0 0 0 1 1 1 0 1 1 1]
[1 0 0 1 1 1 1 0 0 0]
[0 1 1 0 1 1 0 1 0 0]
[1 1 1 1 0 1 0 0 1 0]
[1 1 1 1 1 0 0 0 0 1]
[1 0 1 0 0 0 0 1 1 1]
[0 1 0 1 0 0 1 0 1 1]
[1 1 0 0 1 0 1 1 0 1]
[1 1 0 0 0 1 1 1 1 0]
sage: G = Graph(M); G
Graph on 10 vertices
sage: G.plot().show()
</code></pre>
<p>Here is the error.</p>
<pre><code>Traceback (most recent call last): [0 0 0 1 1 1 0 1 1 1]
File "", line 1, in <module>
File "/private/var/folders/sw/0pqlf1452k58z_jbk3_yv5m97h2tyd/T/tmpabbyzH/___code___.py", line 5
G = Graph(M); G
^
SyntaxError: invalid syntax
</code></pre>
https://ask.sagemath.org/question/33456/traceback-error/?comment=33523#post-id-33523I am sorry for my late reply. Here is the information.
To answer @tmonteil:
- I am using SageMath-7.1
- OS X El Capitan
- I don't know if Sage was installed from the binaries. The IT support staff for the department installed SageMath on these (department) computers.
- Did I compile Sage myself? I'm sorry, I don't know what you mean.
- I used Sage notebook
- No, I did not use the command line.
To answer @FrédéricC:
No, to my knowledge there was no output of `sage M`.Mon, 23 May 2016 18:17:43 +0200https://ask.sagemath.org/question/33456/traceback-error/?comment=33523#post-id-33523Answer by paulmasson for <p>Hello,</p>
<p>I am new to Sage Math and new to this forum. Basically, I have written code to generate a specific graph on 10 vertices from its adjacency matrix. I am receiving an error (pasted below), but when my advisor runs the same exact code on his machine, he does not receive an error. I do not know how to resolve this situation. I've pasted my code below, and the error that I receive follows. Any insight would be much appreciated, and let me know if you need more details (e.g., information about the machine I'm using, operating system, etc.).</p>
<pre><code>sage: M = Matrix([(0,0,1,0,1,1,1,0,1,1), (0,0,0,1,1,1,0,1,1,1), \
(1,0,0,1,1,1,1,0,0,0), (0,1,1,0,1,1,0,1,0,0), (1,1,1,1,0,1,0,0,1,0), \
(1,1,1,1,1,0,0,0,0,1), (1,0,1,0,0,0,0,1,1,1), (0,1,0,1,0,0,1,0,1,1), \
(1,1,0,0,1,0,1,1,0,1), (1,1,0,0,0,1,1,1,1,0)])
sage: M
[0 0 1 0 1 1 1 0 1 1]
[0 0 0 1 1 1 0 1 1 1]
[1 0 0 1 1 1 1 0 0 0]
[0 1 1 0 1 1 0 1 0 0]
[1 1 1 1 0 1 0 0 1 0]
[1 1 1 1 1 0 0 0 0 1]
[1 0 1 0 0 0 0 1 1 1]
[0 1 0 1 0 0 1 0 1 1]
[1 1 0 0 1 0 1 1 0 1]
[1 1 0 0 0 1 1 1 1 0]
sage: G = Graph(M); G
Graph on 10 vertices
sage: G.plot().show()
</code></pre>
<p>Here is the error.</p>
<pre><code>Traceback (most recent call last): [0 0 0 1 1 1 0 1 1 1]
File "", line 1, in <module>
File "/private/var/folders/sw/0pqlf1452k58z_jbk3_yv5m97h2tyd/T/tmpabbyzH/___code___.py", line 5
G = Graph(M); G
^
SyntaxError: invalid syntax
</code></pre>
https://ask.sagemath.org/question/33456/traceback-error/?answer=33511#post-id-33511As indicated by @FrédéricC, make sure your input does not include previous output results. Here's an [example](http://sagecell.sagemath.org/?z=eJzzVbBV8E0sKcqs0IjWMNAx0DEEY0MYramjABZGEQQJ83JpGCKJQ9gGEOUIhRDzwMKGSCZALYKagmICSAai3ABZCOEWFBOQ3IIihjDFENkEsKWxmrxcvFzuQI-7FyUWZGj4Qvh6BTn5JRqaesUZ-eUamgChYTTp&lang=sage) on the SageMathCell server showing just the three inputs and the final graph. This server does not show the `sage: ` command line prompt, but that should be the only difference from what you're doing.
You can also copy all three inputs on one line if you include semicolons between them, as in this [example](http://sagecell.sagemath.org/?z=eJzzVbBV8E0sKcqs0IjWMNAx0DEEY0MYramjABZGEYQIGyIJQ9gGENUIdRDjDCCqDZGFQCSyMNQAkATMbCQhhEtQDEC4BEUIYYghsgFgK2M1FawV3IGedi9KLMjQ8AVz9Qpy8ks0NPWKM_LLNTQBG2c1ng==&lang=sage).
I've learned through trial and error that you don't need Python line continuation indicators when the arguments of a SageMath function take multiple line. In your case it's the backslashes "\" in the definition of M, which I've removed just to make it look a bit cleaner.Sun, 22 May 2016 22:34:44 +0200https://ask.sagemath.org/question/33456/traceback-error/?answer=33511#post-id-33511Comment by JEA for <p>As indicated by <a href="/users/1557/fredericc/">@FrédéricC</a>, make sure your input does not include previous output results. Here's an <a href="http://sagecell.sagemath.org/?z=eJzzVbBV8E0sKcqs0IjWMNAx0DEEY0MYramjABZGEQQJ83JpGCKJQ9gGEOUIhRDzwMKGSCZALYKagmICSAai3ABZCOEWFBOQ3IIihjDFENkEsKWxmrxcvFzuQI-7FyUWZGj4Qvh6BTn5JRqaesUZ-eUamgChYTTp&lang=sage">example</a> on the SageMathCell server showing just the three inputs and the final graph. This server does not show the <code>sage:</code> command line prompt, but that should be the only difference from what you're doing.</p>
<p>You can also copy all three inputs on one line if you include semicolons between them, as in this <a href="http://sagecell.sagemath.org/?z=eJzzVbBV8E0sKcqs0IjWMNAx0DEEY0MYramjABZGEYQIGyIJQ9gGENUIdRDjDCCqDZGFQCSyMNQAkATMbCQhhEtQDEC4BEUIYYghsgFgK2M1FawV3IGedi9KLMjQ8AVz9Qpy8ks0NPWKM_LLNTQBG2c1ng==&lang=sage">example</a>.</p>
<p>I've learned through trial and error that you don't need Python line continuation indicators when the arguments of a SageMath function take multiple line. In your case it's the backslashes "\" in the definition of M, which I've removed just to make it look a bit cleaner.</p>
https://ask.sagemath.org/question/33456/traceback-error/?comment=33524#post-id-33524Ahh, thank you! This helps a lot! And thanks to @FrédéricC and also to @tmonteil for their time.Mon, 23 May 2016 18:25:47 +0200https://ask.sagemath.org/question/33456/traceback-error/?comment=33524#post-id-33524