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, 27 Jul 2013 11:24:38 +0200Does or will Sage support the Visual Python module?https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/Does or will Sage support the Visual Python (http://vpython.org/) module?
I use it to create 3D examples for several of my courses including Calculus III, Differential Equations, Modern Algebra, Combinatorics and my students use it for projects in both Modern Algebra and Scientific Computation.
Adam Hausknecht, Department of Mathematics, UMass DartmouthSun, 08 Jan 2012 17:03:14 +0100https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/Answer by Shashank for <p>Does or will Sage support the Visual Python (<a href="http://vpython.org/">http://vpython.org/</a>) module? </p>
<p>I use it to create 3D examples for several of my courses including Calculus III, Differential Equations, Modern Algebra, Combinatorics and my students use it for projects in both Modern Algebra and Scientific Computation.</p>
<p>Adam Hausknecht, Department of Mathematics, UMass Dartmouth</p>
https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?answer=13101#post-id-13101You can use any python module in sage. I just tried a simple example in sage, but it opens in a new window and not in the browser itself. You have to however import the module from the outside, as visual is not part of sage yet. Just try the following to see whether you can get visual python working with sage. It works for me.
import sys
sys.path.append('/usr/lib/python2.7/dist-packages')
from visual import *
sphere()
Note, that depending on the version of python you are using the path to the visual module may differ on your machine. Sun, 08 Jan 2012 18:07:32 +0100https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?answer=13101#post-id-13101Comment by Simon King for <p>You can use any python module in sage. I just tried a simple example in sage, but it opens in a new window and not in the browser itself. You have to however import the module from the outside, as visual is not part of sage yet. Just try the following to see whether you can get visual python working with sage. It works for me.</p>
<pre><code>import sys
sys.path.append('/usr/lib/python2.7/dist-packages')
from visual import *
sphere()
</code></pre>
<p>Note, that depending on the version of python you are using the path to the visual module may differ on your machine. </p>
https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?comment=20567#post-id-20567Too bad, I thought I can have line breaks in a comment. Anyway: In order to install any new Python module in Sage, just open a Sage shell (i.e., if "sage" is the command for launching an interactive Sage session, do "sage -sh"). In that shell, the commands "singular", "gap", "python" and so on will refer to Sage's own versions of Singular, GAP and python. Hence, in the Sage shell, you'd just do whatever needed to install the package, and then it will automatically be in the right version of Python.Mon, 09 Jan 2012 03:53:46 +0100https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?comment=20567#post-id-20567Comment by tririver for <p>You can use any python module in sage. I just tried a simple example in sage, but it opens in a new window and not in the browser itself. You have to however import the module from the outside, as visual is not part of sage yet. Just try the following to see whether you can get visual python working with sage. It works for me.</p>
<pre><code>import sys
sys.path.append('/usr/lib/python2.7/dist-packages')
from visual import *
sphere()
</code></pre>
<p>Note, that depending on the version of python you are using the path to the visual module may differ on your machine. </p>
https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?comment=20566#post-id-20566Alternatively, I like to do things the other way round. Write a Python (2.x) package and use "from sage import *" to use sage functions. Then it should work with everything.Mon, 09 Jan 2012 07:56:29 +0100https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?comment=20566#post-id-20566Comment by Simon King for <p>You can use any python module in sage. I just tried a simple example in sage, but it opens in a new window and not in the browser itself. You have to however import the module from the outside, as visual is not part of sage yet. Just try the following to see whether you can get visual python working with sage. It works for me.</p>
<pre><code>import sys
sys.path.append('/usr/lib/python2.7/dist-packages')
from visual import *
sphere()
</code></pre>
<p>Note, that depending on the version of python you are using the path to the visual module may differ on your machine. </p>
https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?comment=20568#post-id-20568Note that Sage has its own Python. Hence, rather than using "visual" from the global Python version on your machine (which may be a different version than Sage's Python!), I think it would be better to install the visual module into Sage's PythonMon, 09 Jan 2012 03:50:18 +0100https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?comment=20568#post-id-20568Answer by ahausknecht for <p>Does or will Sage support the Visual Python (<a href="http://vpython.org/">http://vpython.org/</a>) module? </p>
<p>I use it to create 3D examples for several of my courses including Calculus III, Differential Equations, Modern Algebra, Combinatorics and my students use it for projects in both Modern Algebra and Scientific Computation.</p>
<p>Adam Hausknecht, Department of Mathematics, UMass Dartmouth</p>
https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?answer=13105#post-id-13105Hi all,
Thanks for your responses! Om my MacBook Pro Intel Core I7, I had to change the suggested lines of code to:
--------------------------------------
import sys
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages')
import visual
------------------
However, when this is evaluated by Sage, I get the error message:
------------------------------
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_19.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("aW1wb3J0IHN5cwpzeXMucGF0aC5hcHBlbmQoJy9MaWJyYXJ5L0ZyYW1ld29ya3MvUHl0aG9uLmZyYW1ld29yay9WZXJzaW9ucy8yLjcvbGliL3B5dGhvbjIuNy9zaXRlLXBhY2thZ2VzJykKaW1wb3J0IHZpc3VhbA=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/private/var/folders/45/450VCFXnGmmTeo+fv0sWMk+++TI/-Tmp-/tmp3XxlCy/___code___.py", line 4, in <module>
exec compile(u'import visual
File "", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/visual/__init__.py", line 1, in <module>
from .visual_all import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/visual/visual_all.py", line 1, in <module>
from vis import version
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vis/__init__.py", line 3, in <module>
from .cvisual import (vector, dot, mag, mag2, norm, cross, rotate,
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vis/cvisual.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vis/cvisual.so: mach-o, but wrong architecture
---------------------------------------------------
I take this to mean that the visual python package has been compiled for an architecture that
is incompatible with Sage.
Note: I used the Mac OS installer at
http://vpython.org/contents/download_mac.html
to install Visual Python as a Mac OS Framework; consequently, vPython is not installed in the
same manner as most Python packages!
Regards,
Adam Hausknecht
Mon, 09 Jan 2012 13:26:52 +0100https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?answer=13105#post-id-13105Comment by Xander Nerdski for <p>Hi all, </p>
<h2>Thanks for your responses! Om my MacBook Pro Intel Core I7, I had to change the suggested lines of code to:</h2>
<p>import sys
sys.path.append('/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages')</p>
<h2>import visual</h2>
<p>However, when this is evaluated by Sage, I get the error message:</p>
<hr/>
<p>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_19.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -<em>- coding: utf-8 -</em>-\n" + _support_.preparse_worksheet_cell(base64.b64decode("aW1wb3J0IHN5cwpzeXMucGF0aC5hcHBlbmQoJy9MaWJyYXJ5L0ZyYW1ld29ya3MvUHl0aG9uLmZyYW1ld29yay9WZXJzaW9ucy8yLjcvbGliL3B5dGhvbjIuNy9zaXRlLXBhY2thZ2VzJykKaW1wb3J0IHZpc3VhbA=="),globals())+"\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module></p>
<p>File "/private/var/folders/45/450VCFXnGmmTeo+fv0sWMk+++TI/-Tmp-/tmp3XxlCy/___code___.py", line 4, in <module>
exec compile(u'import visual
File "", line 1, in <module></p>
<p>File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/visual/__init__.py", line 1, in <module>
from .visual_all import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/visual/visual_all.py", line 1, in <module>
from vis import version
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vis/__init__.py", line 3, in <module>
from .cvisual import (vector, dot, mag, mag2, norm, cross, rotate,
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vis/cvisual.so, 2): no suitable image found. Did find:</p>
<h2> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vis/cvisual.so: mach-o, but wrong architecture</h2>
<p>I take this to mean that the visual python package has been compiled for an architecture that
is incompatible with Sage. </p>
<p>Note: I used the Mac OS installer at </p>
<pre><code> http://vpython.org/contents/download_mac.html
</code></pre>
<p>to install Visual Python as a Mac OS Framework; consequently, vPython is not installed in the
same manner as most Python packages!</p>
<p>Regards, </p>
<p>Adam Hausknecht</p>
https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?comment=17233#post-id-17233I have same symptom ". . .vis/cvisual.so: mach-o, but wrong architecture)\" when I attempt to run VIDLE. Unfortunately, I have not been able to figure out how to fix it. Sat, 27 Jul 2013 11:24:38 +0200https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?comment=17233#post-id-17233Answer by Simon King for <p>Does or will Sage support the Visual Python (<a href="http://vpython.org/">http://vpython.org/</a>) module? </p>
<p>I use it to create 3D examples for several of my courses including Calculus III, Differential Equations, Modern Algebra, Combinatorics and my students use it for projects in both Modern Algebra and Scientific Computation.</p>
<p>Adam Hausknecht, Department of Mathematics, UMass Dartmouth</p>
https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?answer=13106#post-id-13106As I said in a comment above: It is not recommended to install some package in one python installation (e.g., some system-wide installation) and then import it into a *totally different* installation (e.g., the Sage installation).
It is important to keep in mind that Sage includes "batteries": It includes Python, it includes GAP, it includes Maxima, Singular, you name it. Hence, when you want to use a specific Python package in Sage then you should install it in Sage's Python, and nowhere else.
Hence, open a Sage shell (if sage is in your path then do "sage -sh"), and then do whatever is needed to install the package. Namely, in the Sage shell, "python" and "gap" and "singular" will automatically be Sage's versions, not the system-wide versions.Mon, 09 Jan 2012 14:37:52 +0100https://ask.sagemath.org/question/8616/does-or-will-sage-support-the-visual-python-module/?answer=13106#post-id-13106