My Jupyter notebook is displaying text rather than ipywidgets. Here is a screenshot:
I read several posts about similar problems, like this one:
Jupyter Notebook not rendering ipywidgets.
Most of them indicate that the solution is to enable an extension, e.g: https://stackoverflow.com/a/38001920/11692496
But it seems to apply to older version of jupyter notebooks. I tried it anyway (with the --sys-prefix argument, which is required for virtualenv), but it didn't fix it.
I'm working with a jupyter notebook and a virtualenv. Just to be sure, I created a fresh venv and installed the minimal packages. No luck.
I'm using Python 3.10.6 and here is my versions list:
Thanks for your help!
For the record, I didn't manage to solve this issue on my virtualenv.
As #Wayne suggested above, I went for a workaround, namely a docker container based on jupyter/tensorflow-notebook
Related
I am using Python in a Jupyter Lab notebook in a Docker container. I have the following code in one cell:
import numpy as np
import os
import pandas as pd
Then I run the following cell:
!pipreqs /app/loaded_reqs
and get:
INFO: Successfully saved requirements file in /app/loaded_reqs/requirements.txt
But when I open the requirements.txt, it shows up empty/blank. I expected numpy, os and pandas to be in this requirements.txt file. Why might it not be working?
According to this Medium post by Iván Lengyel, pipreqs doesn't support Jupyter notebooks. (This issue in in the pipreqs repo, open since 2016 convinces me of the veracity of that assertion. Nicely, the issue post also suggests the solution I had already found when searching the terms 'pipreqs jupyter' at Google.) Plus, importantly you generally don't use tools that act on notebook files inside the notebook you are trying to use. (Or at least it is something to always watch out for, [or test if possible], similar in a way to avoiding iterating on a list you are modifying in the loop.)
Solution -- use pipreqsnb instead:
In that Medium post saying it doesn't work with notebooks, Iván Lengyel proffers a wrapper for it that works for notebooks. So in the terminal outside the notebook, but in the same environment (inside the docker container, in your case), install pipreqsnb via pip install pipreqsnb. Then run it pointing it at your specific notebook file. I'll give an example in the next paragraph.
I just tried it and it worked in temporary sessions launched from here by pressing launch binder badge there. When the session came up, I opened a terminal and ran pip install pipreqsnb and then pipreqsnb index.ipynb. That first time I saw requirements.txt get made with details on the versions of matplotlib, numpy, scipy, and seaborn. To fully test it was working, I opened index.ipynb in the running session and added a cell with import pandas as pd typed in it and saved the notebook. Then I shutdown the kernel and over in the terminal ran, pipreqsnb index.ipynb. When I re-examined the requirements.txt file now pandas has been added with details about the versions.
More about maybe why !pipreqs /app/loaded_reqs failed:
I had the idea that maybe you needed to save the notebook first after adding the import statements cell? However, nevermind. That still won't help because as stated here pipreqs, and further confirmed at the pipreqs issues list doesn't support Jupyter notebooks.
Also, keep in mind the use of the exclamation in a notebook to run a command in the shell doesn't mean that shell will be in the same environment as the kernel of the notebook, see the second paragraph here to more perspective on that. (This can be useful to understand for future things though, such as why you want to use the %pip or %conda magic commands when installing from inside a notebook, see here, and not put an exclamation point in front of that command in modern Jupyter.)
Or inside the notebook at the end, I'd suggest trying %watermark --iversions, see watermark. And then making some code to generate the requirements.txt from that. (Also, I had seen there was bug in that related to some packages imported with from X import Y, see here.)
Or I'd suggest trying %pip freeze inside the notebook for the full environment information. Not just what the file needs, though.
I am having a problem with creating a new ipython notebook.
Previously I used to do that going to new -> python
but now I am unable to see any python option.
Also, I am unable to open any ipython notebooks, I have one uploading for hours now.
I recently erased my %temp% folder to free some space in the C drive. Does that have something to do with this? How do I fix this?
I solved the problem!
For some reason, jupyter labs was not installed
So running the command
jupyter -- version
and then checking what all was installed, I found out that jupyter labs was not installed?
pip3 install jupyter labs
so I went ahead and installed it and everything works as it did before.
Still don't know the reason why this all happened in particular. If anyone could help me with that'd be awesome!
I'm not sure 100% but this is most commonly related to an ipython jupyter notebook file error. I do recommend to do a clean install of the notebook and try again. As I don't have any specifications on your system is difficult to guide you on the process. But that is the best option you have now.
Also this could have happened because of an update on python, jupyter, your system or any base component required by jupyter or python.
I have set up a Jupyter notebook on an AWS box, or so I thought. When I try jupyter notebook, however, I get this:
[C 16:22:30.841 NotebookApp] The 'kernel_spec_manager_class' trait of instance must be a type, but 'environment_kernels.EnvironmentKernelSpecManager' could not be imported
Any suggestions on how to fix?
EDIT actually, when I run jupyter notebook in the base environment, it works (I can't connect to it, but that's obviously a separate problem). However, in a "nonstandard" environment, it does not start. To answer the questions, this is an ubuntu 18.04 deep learning image, and in the environment I had installed jupyter and jupyterlab (via anaconda)
The issue seems to be same as the one described here:
environment_kernels.EnvironmentKernelSpecManager could not be imported
Since in your question you have not indicated that you've tried that, I think that the solution proposed in the link could be tried:
pip install environment_kernels
I am not able to display the charts on jupyter notebook. The same code displays on chrome in one laptop but does not work on chrome on other laptop.
I do not see any error or even a empty plot when I execute the code but get alt.Chart(...) in the output.
The version of altair and vega etc are same on both the laptops.
For 'altair' version of '4.1.0',
'vega' version of '3.4.0'
just do alt.renderers.enable('default') instead of
alt.renderers.enable('notebook')
If it works in one notebook and not another, there are a couple possibilities for what is going on:
your notebooks are connected to different kernels with different versions of Altair and/or its dependencies installed. Run the following
import sys
print(sys.executable)
to see if you're using the same Python executable in your environments. If the results are different, you can use Kernel -> Change Kernel in the Jupyter notebook menu to change to a kernel with a working Altair version.
If that's not the case, then it is likely that you have inadvertently enabled a different renderer in one of the notebooks, for example by running alt.renderers.enable('notebook'). In Altair 4.0, the default renderer should work out-of-the-box in both Jupyter notebook and JupyterLab. Either restart your kernel or run alt.renderers.enable('default') to restore the default.
The behavior above can happen if you have too old a version of IPython installed. See If the notebook displays on one laptop and not the other, it may be that the broken one has too old a version of IPython installed. See https://altair-viz.github.io/user_guide/troubleshooting.html#notebook-textual-chart-representation for more information on what to upgrade.
See Altair's Display Troubleshooting guide for more information.
I've a problem when I updated notebook to Jupiter.
The menubar and tools are missing like in the following image.
I'm on Kubuntu14.04. I tried installing via different methods and version of python. Same for any browsers. No warnings when launching notebook.
Someone have the same problem on windows (here).
If you have any ideas.
Thank you.
Fixed removing ipython and major part of Jupyter traces and reinstalling everything from anaconda.