Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added a workaround for Jupyter notebooks #7990

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

Merged
merged 1 commit into from
Apr 17, 2017
Merged

Added a workaround for Jupyter notebooks #7990

merged 1 commit into from
Apr 17, 2017

Conversation

mapio
Copy link
Contributor

@mapio mapio commented Jan 30, 2017

Added a link to https://github.com/mapio/jupyter-virtualenv-osx that can solve the issue for Jupyter notebook users.

Added a link to https://github.com/mapio/jupyter-virtualenv-osx that can solve the issue for Jupyter notebook users.
@NelleV
Copy link
Member

NelleV commented Jan 30, 2017

@Carreau Do you mind having a look at this PR as an OSX user and an IPython/Jupyter developer?

@mapio
Copy link
Contributor Author

mapio commented Jan 30, 2017

In a discussion on Reddit https://www.reddit.com/r/Python/comments/5qwzif/mapiojupytervirtualenvosx_a_tool_to_install_a/ a supposedly easier solution is suggested. Unfortunately, I've tested it and in my opinion it works only with Python 3, or with IPython (and not Jupyter notebooks). In any case @Carreau should probably double check in case I'm wrong.

@jenshnielsen
Copy link
Member

@mapio That solution is already in our f.a.q http://matplotlib.org/devdocs/faq/osx_framework.html#virtualenv venv does indeed not have this issue which virtualenv has but is not available for python 2

@mapio
Copy link
Contributor Author

mapio commented Jan 30, 2017

@jenshnielsen yes, and I missed that the OP edited the comment admitting that it does not work for Python 2.7.

So I think that my edit to the documentation will offer a simple solution for OS X users that want to run Jupyter under Python 2.7.

@Carreau
Copy link
Contributor

Carreau commented Jan 30, 2017

One of the drawback of this (in particular the instruction , not the script itself) is it will install jupyter in all the environments if you use several, while what most people want (or should do) when installing jupyter is have the notebook server installed once (either in the system/root env/another env, I don't care, up to them) and then install likely only ipykernel in their env.

That is due to the confusion that jupyter does not need to be installed on the Python that are used when you import libraries, so technically you don't really care whether the jupyter use a framework Python or not. For the sake of argument Jupyter could be written in Go or Haskell, and what you care is where IPython (technically IPykernel and dependencies) are installed.

Also at some point in the future probably around 2020, we'll start requiring python 3 for some components of the notebook server (we do already for JupyterHub). So users will need to have both a Python 3 and a Python 2 env to run Python 2 code in the notebooks. Hence the distinction will need to understood at some point[1].

I must point out that the repo is 23h old also.

In the other hand it seem to solve people problems, and @mapio took the time to write this script. I'm guessing many users won't deal with multiple envs, so for them this may "just work" and make the experience much better. It would still be nice to figure out how to make the installation clean without having to deal with scripts in all the places though. This might be a first step.

[1]: There've been some discussion with the conda for a "Python 3 env" to be able to be a "dependendency" on a Python 2 package, so that conda install jupyter would install the python 3 deps in a shadow env.

@mapio
Copy link
Contributor Author

mapio commented Jan 30, 2017

I do agree @Carreau that the confusion about Jupyter must be cleared – and I'd like you to help me better understand the situation here.

The only "new" thing the script does is to use the env kernel metadata to set PYTHONHOME, to allow IPython kernel to use a Framework Python, but to access the virtualenv.

This works both if you install Jupyter in the virtualenv, or not — and, for what matters, even if you install the IPython kernel in the virtualenv or not.

Presently the only dependency of the script is on KernelSpecManager from the jupyter_client.kernelspec package, given that I use its install_kernel_spec to install my handcrafted config.json.

But if a user wants to use Jupyter, he must have such package installed (in the system, or virtualenv, package directory).

I'll try to edit the README.md to better reflect this (and avoid the confusion).

@mapio
Copy link
Contributor Author

mapio commented Jan 30, 2017

That's it @Carreau, mapio/jupyter-virtualenv-osx@2590f65 I've reworded the README.md (and fixed a couple of bugs).

I'd love if you consider this for merging :-)

@anntzer
Copy link
Contributor

anntzer commented Apr 16, 2017

@Carreau Do you mind re-reviewing the PR? (more specifically whether the improvements to the script solve the issue you have mentioned)
Superficially it looks good to me.

@Carreau
Copy link
Contributor

Carreau commented Apr 16, 2017

Seem better this way.

+1. Thanks @mapio.

@anntzer anntzer changed the title Added a workaround for Jupyter notebooks [MRG+1] Added a workaround for Jupyter notebooks Apr 16, 2017
@tacaswell tacaswell merged commit b58ccb9 into matplotlib:master Apr 17, 2017
tacaswell added a commit that referenced this pull request Apr 17, 2017
DOC: Add dcos for Jupyter notebooks with virtualenv on OSX
@tacaswell
Copy link
Member

backported to v2.0.0-doc as d0676a9

@QuLogic QuLogic added this to the 2.0.1 (next bug fix release) milestone Apr 17, 2017
@QuLogic QuLogic changed the title [MRG+1] Added a workaround for Jupyter notebooks Added a workaround for Jupyter notebooks Apr 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants