The JupyterLab application must be installed in the codespace you are opening. The default dev container image includes JupyterLab, so codespaces created from the default image will always have JupyterLab installed. For more information about the default image, see "Introduction to dev containers" and the devcontainers/images repository. If you're not using the default image in your dev container configuration, you can install JupyterLab by adding the ghcr.io/devcontainers/features/python feature to your devcontainer.json file. You should include the option "installJupyterlab": true. For more information, see the README for the python feature, in the devcontainers/features repository.
The reason for this stems from a fundamental incompatibility between the format Jupyter notebooks use (JSON) and the format that git conflict markers assume by default (plain lines of text). This is what it looks like when git adds its conflict markers to a notebook:
With a single line of configuration, we can ask git to call our python script, instead of its default line-based implementation, any time it is merging changes. nbdev_install_hooks sets up this configuration automatically, so after running it, git conflicts become much less common, and never result in broken notebooks.
In nbdev v1 Sylvain Gugger created an amazing tool called nbdev_fix_merge which used very clever custom logic to manually fix merge conflicts in notebooks, to ensure that they could opened in Jupyter. For nbdev v2 I did a from-scratch rewrite of every part of the library, and I realised that we could replace the custom logic with the SequenceMatcher approach described above.
Papermill can also target cloud storage outputs for hosting rendered notebooks,execute notebooks from custom Python code, and even be used within distributeddata pipelines like Dagster (seeDagstermill). For moreinformation, see the papermill documentation.
Jupyter notebooks and git are powerful tools for machine learning engineersand data scientists to prototype solutions and collaborate on a shared codebase.We discussed some tips and tricks for getting the best of both worlds fromnotebooks and version control in our simple financial example from PatagoniaCapital.
Working on my R package ptools, the devtools folks have you make a readme R markdown file to compile to a nice readme markdown file for github. I thought to myself that you could functionally do the same thing with juypter notebooks for python. So here is a quick example of that for my retenmod python package.
You might typically want to add in README.ipynb to your gitignore file, but here I included it in the github package so you can see what this notebook looks like. To compile the notebook to markdown is quite simple:
Fundamentally the problem is usually rooted in the fact that the Jupyter kernels are disconnected from Jupyter's shell; in other words, the installer points to a different Python version than is being used in the notebook.In the simplest contexts this issue does not arise, but when it does, debugging the problem requires knowledge of the intricacies of the operating system, the intricacies of Python package installation, and the intricacies of Jupyter itself.In other words, the Jupyter notebook, like all abstractions, is leaky.
For various reasons that I'll outline more fully below, this will not generally work if you want to use these installed packages from the current notebook, though it may work in the simplest cases.
The root of the issue is this: the shell environment is determined when the Jupyter notebook is launched, while the Python executable is determined by the kernel, and the two do not necessarily match.In other words, there is no guarantee that the python, pip, and conda in your $PATH will be compatible with the python executable used by the notebook.
So, in summary, the reason that installation of packages in the Jupyter notebook is fraught with difficulty is fundamentally that Jupyter's shell environment and Python kernel are mismatched, and that means that you have to do more than simply pip install or conda install to make things work.The exception is the special case where you run jupyter notebook from the same Python environment to which your kernel points; in that case the simple installation approach should work.
After proposing some simple solutions that can be used today, I went into a detailed explanation of why these solutions are necessary: it comes down to the fact that in Jupyter, the kernel is disconnected from the shell.The kernel environment can be changed at runtime, while the shell environment is determined when the notebook is launched.The fact that a full explanation took so many words and touched so many concepts, I think, indicates a real usability issue for the Jupyter ecosystem, and so I proposed a few possible avenues that the community might adopt to try to streamline the experience for users.
Nbviewer is simple and effective for quick sharing because doesn't require user accounts, making it easy to use. However, like GitHub, it renders notebooks as static web pages. It's not suitable for real-time collaboration or for sharing with someone who may want to interact with the data. Another important caveat if that your notebook must be accessible from internet as this is not desirable in many cases.
Binder is an open-source platform that allows you to turn a GitHub repository into a collection of interactive notebooks. Launched as part of Project Jupyter, it offers a way to share fully interactive Jupyter notebooks without any setup required from the end user.
Using VS Code, you can develop and run notebooks against remotes and containers. To make the transition easier from Azure Notebooks, we have made the container image available so it can use with VS Code too.
Google Colab is a web-based Jupyter notebook environment that allows you to write and execute Python code. You can share and edit your code at the same time as other team members and document the project using charts, images, LaTeX, and HTML. Google Colab is often used to code for artificial intelligence (AI) projects and the subset of AI called machine learning (ML). You can use it to work on any Python project, from educational projects to data analysis. If you want to get a full rundown of what he platform is and how it works, check out our Google Colab guide.
There are also demonstration sites in the cloud, such as tmpnb.org. These start an interactive session where you can upload an existing notebook or create a new one from scratch. Though convenient, these sites are intended mainly for demonstration and generally quite overloaded. More significantly, there is no way to retain your work between sessions, and some python functionality is removed for security reasons.
This will both synchronize the working Jupyter notebooks with the pythonversion and also execute the notebooks. So if there is an error in a notebook,this may stop part-way through. If this happens, try the simpler:
Whichever of those you ran, now you can use Jupyter Lab to workwith the notebooks as per normal. You may see a strange message aboutrebuilding and jupytext; just hit okay. The jupytext code should ensure that asyou manipulate the notebook, the plain python is kept in sync (it contains only theinputs, not the outputs).
This notebook performs a function quite similar to the 'sliderPlugin' example.Browser side visualisation is actionable and triggers recalculations in the ipython backend.While the sliderPlugin connects to the kernel, we use IPython's facilities : interact does the lifting for us.
The $AM574/notebooks directory (see Class GitHub Repository) contains somenotebooks developed for this class. You should be able to run them on yourcomputer if you have Jupyter installed (see jupyter.org), after starting the jupyter serverusing this command from the bash shell:
You can also view the notebooks without executing them nativelyin GitHub just by clicking on them. You can also use nbviewer.Copy the URL from a notebook in the repo, then go tonbviewer.org and paste the notebook URLinto the text box.
Each interactive lesson and exercise will have a launch button for both Binder and CSC Notebook.The CSC notebooks environment is only accessible to students from Finnish universities and research institutes.
Notebook images are supported for a minimum of one year. Major updates to pre-configured notebook images occur approximately every six months. Therefore, two supported notebook images are typically available at any given time. You can use this support period to update your code to use components from the latest available notebook image.
The material in this tutorial is specific to PYNQ. Wherever possible, however, it re-uses generic documentation describing Jupyter notebooks. In particular, we have re-used content from the following example notebooks:
If you are reading this documentation from the webpage, you should note that the webpage is a static html version of the notebook from which it was generated. If the PYNQ platform is available, you can open this notebook from the getting_started folder in the PYNQ Jupyter landing page.
Furthermore, any notebook document available from a public URL or on GitHub can be shared via nbviewer. This service loads the notebook document from the URL and renders it as a static web page. The resulting web page may thus be shared with others without their needing to install the Jupyter Notebook.
With the Temp View created, you can use SparkSQL to retrieve the GitHub data for reporting, visualization, and analysis.% sqlSELECT Name, Email FROM SAMPLE_VIEW ORDER BY Email DESC LIMIT 5The data from GitHub is only available in the target notebook. If you want to use it with other users, save it as a table.
df19127ead