New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jupyter #399
Conversation
It does. If people install Jupiter later they just have to reinstall xonsh. This is really great. I have some unfinished attempts to implement this as well. I am glad you found the time to do it the right way. I will try it out as soon as possible :) |
Ok. The first problem I encountered was that the kernel spec was not installed correctly when building conda packages. I have created PR to your jupyter branch that fixes this. I haven't got the kernel to work though. It seems to start correctly even though I get this error
But the notebook does't show any output when entering commands. |
Hi @melund - Awesome :) As per the issue that you are having, have you installed |
I am using IPython 4.0, and jupyter_client is installed.. I will test again tomorrow. |
"codemirror_mode":"shell", | ||
} | ||
if CONDA: | ||
d = os.path.join(os.environ['PREFIX'] + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the same as sys.prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. You are right. It has been a while since I tingled with these things. It is of course python in the build environment that runs setup.py, so it should be the same sys.prefix, when building.
I am not too happy about this being in the setup.py file, but I haven't seen any good ways of installing the kernel_spec with conda. You did something for the r-kernel, right? I think I saw it on conda-recipes, but I can't seem to find it now. Maybe it should be a post-install script that tests if Jupyter is there, and then runs the install_kernel_spec() function.
I don't think conda should have a monopoly on installing things to the install prefix, but maybe that's a more a gripe for jupyter team than xonsh. |
It would be nice if conda could label the kernel_spec file with the environment when installing. Then we would be able to see which environment the kernel belonged to directly from the notebook. Let's say that xonsh was installed in three environments; root, dev and test. In the notebook, it only shows one entry, of the one install last. If the conda installer could change the display_name in the kernel_spec and install it to a different folder (e.g. xonsh_dev), then I would have three entries in the notebook.
Any idea how to do this @asmeurer ? |
If you put the absolute path to the install prefix in a text file, conda will automatically replace it with the path of the install prefix (the environment). I don't know if that gets you what you want. |
That is what we use when creating the kernel_spec. That is also the reason that I convert back-slashes to forward slashes, otherwise the prefix is not replaced. What I wanted was to also write the environment name into the file. Right now on my computer, I create the kernel specs manually, so I can access them all from the same notebook. |
I thought the prefix replacement should work with backslashes. I believe you do need to use only one or the other, though (meaning use |
Hmm. No. The line you are refering to is only used for to create directory in the prefix. The line where backslashes cause problems is sys.prefix in the json file.
|
The backslashes with conda should work. If they aren't you should open an issue in the conda or conda-build issue tracker. |
Is there anything that I actually need to do here? |
Sorry. The discussion got derailed. I still can't get the kernel working. Anything else I could try? |
With pyreadline, everything seems to work fine, but I don't see any output in the notebook. I don't really know what I could easily try. Running it with prompt toolkit gives me a traceback from the kernel:
I don't think that is the solution with conda packages. Setup.py is not run when installing a conda package. That happens only when the package is build. I think the kernel-spec files should be installed by the conda post-install scripts. We should just wait see. I am sure the conda-team will come up with a good way of doing this. |
OK. I have pushed up a temporary fix
I have noticed that sometimes too with respect to expressions that are evaluated. Maybe we could address this in a future PR? Also, OK about the conda stuff. |
Sure. If it works on Linux, the rest could be fixed in an other PR. Are there anyone else who can test on windows. I really don't know if it is only my setup... |
I can see why this error is occurring, but I don't understand how @melund. I have updated the code. Can you test and see if it is giving you an AssertionError now? |
Traceback (most recent call last):
File "C:\Users\mel\Documents\xonsh\xonsh\base_shell.py", line 158, in push
locs=self.ctx)
File "C:\Users\mel\Documents\xonsh\xonsh\execer.py", line 95, in compile
tree = self.parse(input, ctx, mode=mode)
File "C:\Users\mel\Documents\xonsh\xonsh\execer.py", line 70, in parse
tree = self._parse_ctx_free(input, mode=mode)
File "C:\Users\mel\Documents\xonsh\xonsh\execer.py", line 151, in _parse_ctx_free
debug_level=self.debug_level)
File "C:\Users\mel\Documents\xonsh\xonsh\parser.py", line 264, in parse
tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
File "C:\Users\mel\Anaconda3\envs\xonsh\lib\site-packages\ply\yacc.py", line 331, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "C:\Users\mel\Anaconda3\envs\xonsh\lib\site-packages\ply\yacc.py", line 1106, in parseopt_notrack
p.callable(pslice)
File "C:\Users\mel\Documents\xonsh\xonsh\parser.py", line 1627, in p_power
assert False
AssertionError |
Is this only in the notebook or on the command line too? |
Only in the notebook. At the command line it works as I would expect. |
That is super weird. I know you said that it doesn't matter what you type, but can you give me an example, please? Thanks! |
Here is what I type at the command line to start jupyter:
The UNKNOWN MESSAGE TYPE comes before I provoke the traceback.. So it may not be related. |
Ahh, OK. So I think that this is related. I see the same start up message that you do, but without the $ jupyter --version
4.0.6 Also do you have a recent version of ipykernel? The |
Also, this is a very weird part of the code base to consistently be failing at... |
I am using jupyter and notebook from continuum's anaconda repo.
|
I have ipykernel version 4.0.3 |
hmm OK, I was on notebook, version v4.0.4. I updated to v4.0.5 and now I see |
I am also on ipykernel v4.0.3 |
Ok I just opened up an issue on ipykernel |
Also, what version of ply do you have? $ python -c "import ply; print(ply.__version__)" |
I am on v3.6 |
The same as you: |
Uggh This is nasty. Could you try sticking in a pdb or print statement into |
that makes me sad. |
Well, I am so sorry :) |
haha not your fault, of course :) |
It is getting late here, and I am hosting a webinar at work tomorrow. So I will think I will head to bed. I would really like to see if anyone else also have the same issue on windows... Maybe someone who doesn't rely on conda. |
good night! I'll post to the mailing list. |
I am going to go ahead and merge this with the assumption that some support is better than none. We can build off of this. |
Added hooks for Jupyter notebooks to be automatically installed. Now the only thing is that this won't come with the pip or conda packages unless we make the packages dependent on jupyter / ipython. Does this sound reasonable to people?