ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 24 Oct 2018 05:25:33 -0500Cannot get threejs rendering to work on MacOShttp://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/Hey,
I've been trying to get threejs output working for a few days now. My current installation is from Conda-Forge (sage 8.3) and I'm on MacOS High Sierra (10.13.6).
In the sage repl if I run
P = parametric_plot3d([cos(x),sin(x),x/10], (x,0,4*pi))
P.show(viewer='threejs')
sage raises ```ImportError: cannot import name 'THREEJS_DIR'```. Full output: paste2.org/vP4nBZ9A
If I run
P = parametric_plot3d([cos(x),sin(x),x/10], (x,0,4*pi)
P.show(viewer='threejs', online=True)
sage returns ```Launched html viewer for Graphics3d Object```, but nothing actually happens on my machine. No browser opens, nothing noticeable. I have tried changing the default viewer browser, but it has not made a difference. I'm at a loss as to what is going on here.
Finally, if I run it in a jupyter notebook,
p1 = sphere(color='red', opacity='.5')
p2 = sphere((-1,-1,1), color='cyan', opacity='.3')
p3 = sphere((1,-1,-1), color='yellow', opacity='.7')
show(p1 + p2 + p3, viewer='threejs', online=True)
I get ```TypeError: a bytes-like object is required, not 'str'```.
Full traceback here: paste2.org/c1VLUmNm
I've tried pretty hard to diagnose exactly what's going on, but I can't seem to find any recent documentation relating to this issue. My best guess is that the paths are getting messed up because I'm running sage through an anaconda environment. Is there any way to fix this? That being said, I was having similar issues before and wanted to integrate with jupyter which lead to me moving to anaconda. I am going to try and reinstall sage outside of anaconda and see if I can get it to work there, but I figured I should post first because I'm pretty stuck, and having everything in anaconda would be much nicer if possible.Sun, 21 Oct 2018 12:10:46 -0500http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/Answer by saraedum for <p>Hey,</p>
<p>I've been trying to get threejs output working for a few days now. My current installation is from Conda-Forge (sage 8.3) and I'm on MacOS High Sierra (10.13.6).</p>
<p>In the sage repl if I run</p>
<pre><code>P = parametric_plot3d([cos(x),sin(x),x/10], (x,0,4*pi))
P.show(viewer='threejs')
</code></pre>
<p>sage raises <code>ImportError: cannot import name 'THREEJS_DIR'</code>. Full output: paste2.org/vP4nBZ9A</p>
<p>If I run </p>
<pre><code>P = parametric_plot3d([cos(x),sin(x),x/10], (x,0,4*pi)
P.show(viewer='threejs', online=True)
</code></pre>
<p>sage returns <code>Launched html viewer for Graphics3d Object</code>, but nothing actually happens on my machine. No browser opens, nothing noticeable. I have tried changing the default viewer browser, but it has not made a difference. I'm at a loss as to what is going on here.</p>
<p>Finally, if I run it in a jupyter notebook, </p>
<pre><code>p1 = sphere(color='red', opacity='.5')
p2 = sphere((-1,-1,1), color='cyan', opacity='.3')
p3 = sphere((1,-1,-1), color='yellow', opacity='.7')
show(p1 + p2 + p3, viewer='threejs', online=True)
</code></pre>
<p>I get <code>TypeError: a bytes-like object is required, not 'str'</code>.
Full traceback here: paste2.org/c1VLUmNm</p>
<p>I've tried pretty hard to diagnose exactly what's going on, but I can't seem to find any recent documentation relating to this issue. My best guess is that the paths are getting messed up because I'm running sage through an anaconda environment. Is there any way to fix this? That being said, I was having similar issues before and wanted to integrate with jupyter which lead to me moving to anaconda. I am going to try and reinstall sage outside of anaconda and see if I can get it to work there, but I figured I should post first because I'm pretty stuck, and having everything in anaconda would be much nicer if possible.</p>
http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?answer=44050#post-id-44050###Three.js in conda-forge
The `ImportError: cannot import name 'THREEJS_DIR'` is happening in conda-forge because there is no three.js packaged in conda yet. You could open an issue at https://github.com/conda-forge/sage-feedstock so we can work on a fix.
###No browser is launched
I don't know why you don't get any visible output with `online=True`. This seems like something is broken in your local setup. Somewhere in your `.sage` directory (probably `~/.sage/temp`) there should be an HTML file that you could open manually in your browser in the meantime.
To debug what's going on, you could try to run something like
sage: _system = os.system
sage: def system(*args, **kwargs):
....: print(args, kwargs)
....: _system(*args, **kwargs)
....:
sage: os.system = system
sage: P.show(viewer='threejs', online=True)
You should then see the command that sage is trying to run.
###Python3 errors
You should probably open a ticket at trac.sagemath.org about this (after checking that no such ticket exists yet.) Python3 support in Sage is very experimental.
Wed, 24 Oct 2018 05:25:33 -0500http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?answer=44050#post-id-44050Answer by eric_g for <p>Hey,</p>
<p>I've been trying to get threejs output working for a few days now. My current installation is from Conda-Forge (sage 8.3) and I'm on MacOS High Sierra (10.13.6).</p>
<p>In the sage repl if I run</p>
<pre><code>P = parametric_plot3d([cos(x),sin(x),x/10], (x,0,4*pi))
P.show(viewer='threejs')
</code></pre>
<p>sage raises <code>ImportError: cannot import name 'THREEJS_DIR'</code>. Full output: paste2.org/vP4nBZ9A</p>
<p>If I run </p>
<pre><code>P = parametric_plot3d([cos(x),sin(x),x/10], (x,0,4*pi)
P.show(viewer='threejs', online=True)
</code></pre>
<p>sage returns <code>Launched html viewer for Graphics3d Object</code>, but nothing actually happens on my machine. No browser opens, nothing noticeable. I have tried changing the default viewer browser, but it has not made a difference. I'm at a loss as to what is going on here.</p>
<p>Finally, if I run it in a jupyter notebook, </p>
<pre><code>p1 = sphere(color='red', opacity='.5')
p2 = sphere((-1,-1,1), color='cyan', opacity='.3')
p3 = sphere((1,-1,-1), color='yellow', opacity='.7')
show(p1 + p2 + p3, viewer='threejs', online=True)
</code></pre>
<p>I get <code>TypeError: a bytes-like object is required, not 'str'</code>.
Full traceback here: paste2.org/c1VLUmNm</p>
<p>I've tried pretty hard to diagnose exactly what's going on, but I can't seem to find any recent documentation relating to this issue. My best guess is that the paths are getting messed up because I'm running sage through an anaconda environment. Is there any way to fix this? That being said, I was having similar issues before and wanted to integrate with jupyter which lead to me moving to anaconda. I am going to try and reinstall sage outside of anaconda and see if I can get it to work there, but I figured I should post first because I'm pretty stuck, and having everything in anaconda would be much nicer if possible.</p>
http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?answer=44028#post-id-44028It seems that you are using a version of SageMath built with Python3. Alas, Python3 SageMath is not fully ready yet (see [this question](https://ask.sagemath.org/question/43848/python3-migrationstatus/) for a status update, and in particular the [ticket #26212](https://trac.sagemath.org/ticket/26212)). In particular, the `threejs` viewer is not Python3 ready. Mon, 22 Oct 2018 11:55:19 -0500http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?answer=44028#post-id-44028Comment by TristanWL for <p>It seems that you are using a version of SageMath built with Python3. Alas, Python3 SageMath is not fully ready yet (see <a href="https://ask.sagemath.org/question/43848/python3-migrationstatus/">this question</a> for a status update, and in particular the <a href="https://trac.sagemath.org/ticket/26212">ticket #26212</a>). In particular, the <code>threejs</code> viewer is not Python3 ready. </p>
http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?comment=44048#post-id-44048Update: I now have installed Sage8.4 and built using python2.7 without using anaconda. Now I can get the threejs viewer working in a sage notebook, and I no longer get ```ImportError: cannot import name 'THREEJS_DIR'``` with ```Offline=False```.
However, I still am getting ```Launched html viewer for Graphics3d Object``` without any noticeable activity.Tue, 23 Oct 2018 21:32:37 -0500http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?comment=44048#post-id-44048Comment by TristanWL for <p>It seems that you are using a version of SageMath built with Python3. Alas, Python3 SageMath is not fully ready yet (see <a href="https://ask.sagemath.org/question/43848/python3-migrationstatus/">this question</a> for a status update, and in particular the <a href="https://trac.sagemath.org/ticket/26212">ticket #26212</a>). In particular, the <code>threejs</code> viewer is not Python3 ready. </p>
http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?comment=44044#post-id-44044I rebuilt using python2.7 and I'm still having the same issues. The one that I understand the least is why it prints ```Launched html viewer for Graphics3d Object``` and then doesn't open anything.Tue, 23 Oct 2018 15:03:42 -0500http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?comment=44044#post-id-44044Comment by eric_g for <p>It seems that you are using a version of SageMath built with Python3. Alas, Python3 SageMath is not fully ready yet (see <a href="https://ask.sagemath.org/question/43848/python3-migrationstatus/">this question</a> for a status update, and in particular the <a href="https://trac.sagemath.org/ticket/26212">ticket #26212</a>). In particular, the <code>threejs</code> viewer is not Python3 ready. </p>
http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?comment=44041#post-id-44041In console mode yes, but not in the Jupyter notebook: one gets `TypeError: a bytes-like object is required, not 'str'` from function `displayhook` (line 572 of `src/sage/repl/rich_output/backend_ipython.py`). This is with python3-built Sage 8.4.rc1 on Ubuntu 18.04 (I have not tried Sage 8.5.beta0 yet).Tue, 23 Oct 2018 13:35:17 -0500http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?comment=44041#post-id-44041Comment by FrédéricC for <p>It seems that you are using a version of SageMath built with Python3. Alas, Python3 SageMath is not fully ready yet (see <a href="https://ask.sagemath.org/question/43848/python3-migrationstatus/">this question</a> for a status update, and in particular the <a href="https://trac.sagemath.org/ticket/26212">ticket #26212</a>). In particular, the <code>threejs</code> viewer is not Python3 ready. </p>
http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?comment=44040#post-id-44040The threejs works very well for me with a python3-built sage (on Ubuntu).Tue, 23 Oct 2018 09:30:16 -0500http://ask.sagemath.org/question/44014/cannot-get-threejs-rendering-to-work-on-macos/?comment=44040#post-id-44040