Jupyter notebook webpage is a blank screen - python

So I bought this fancy shmancy Codecademy Pro subscription to take the data science track, but it appears that it has a rather disappointing lack of documentation for part six of its course. I'm learning about Python right now, and I just downloaded the newest version of Miniconda, which included Python 3.7.2. I'm trying to open a .zip file (called Reggie's Linear Regression.zip) using the command
jupyter notebook
and it works, to some extent; it automatically launches a Chrome page, but it's just blank. I get this error in the Chrome console:
Refused to execute script from '<URL>' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
I want it to show this file: Reggie_Linear_Regression_Skeleton.ipynb. It just opens in my notes app when I click on it in file explorer.
I'm very new to Python and downloading libraries and stuff (this is actually my first time), so even just pointing me to other resources that would help me with this problem would be helpful as I don't even know how to describe the issue. Also, I'm 100% sure I've navigated to the correct folder in the Anaconda prompt.
Thanks so much

The latest version seems to be broken, try to downgrade jupyter. If you install with Anaconda the command is:
conda install -c anaconda notebook=5.7.4

Yeah, looks like the latest version is broken. There is already a pull request but it is not yet merged https://github.com/jupyter/notebook/pull/4468. That is a pretty simple fix, so you can also do it yourself for the time being https://github.com/jupyter/notebook/pull/4468/files

I was facing the same issue.
Downgrade jupyter notebook. If you face the blank page againg, after opening jupyter notebook on broswer press "ctrl+f5" to force restart the page.

Related

Integrating Python and Jupyter Notebook with Visual Studio Code

Summary:
I am trying to set up the Jupyter Notebook extension for VSCode but I can’t get my Python code snippets to run. There is no "Run" button to select. I can't select a Python/ Jupyter kernel to work with.
The problem in greater detail:
If you check out this YouTube clip at exactly 1 minute and 46 seconds (here - - you can pause it to see the still) this is what I am trying to accomplish.
But here is what my VSCode actually looks like:
As you can see in my screenshot, the “Play” icon to the left of my code snippet is missing. Along the top border, the other “Play All” button is missing.
In Microsoft’s official VSC doc for setting up Jupyter Notebooks, right near the top under this specific heading: “Create or open a Jupyter Notebook” their interface has way more options at the top of the cells when compared to mine. They have buttons named: “Variables”, “Restart”, “Interrupt”. That is expected for Jupyter Notebook funcionality. Mine is missing all of that. Clearly there is something wrong with my setup.
Other SO users report having ms-python extension installed (which includes Jupyter functionality) in addition to stand-alone Jupyter Notebook extensions installed. Apparently in situations when you have multiple Python extensions installed, they can interfere with each other. So after much wrangling, I resolved to uninstalling all my Jupyter extensions and keeping only the main ms-python extension.
The issue persists.
Here is a complete list of all my VSC installed extensions:
$ code --list-extensions --show-versions
arcticicestudio.nord-visual-studio-code#0.19.0
batisteo.vscode-django#1.8.0
bibhasdn.django-html#1.3.0
Compulim.indent4to2#0.1.2
Equinusocio.vsc-community-material-theme#1.4.4
Equinusocio.vsc-material-theme#33.5.0
equinusocio.vsc-material-theme-icons#2.3.1
esbenp.prettier-vscode#9.8.0
formulahendry.code-runner#0.11.8
GulajavaMinistudio.mayukaithemevsc#3.2.3
icrawl.discord-vscode#5.8.0
janisdd.vscode-edit-csv#0.6.10
lonefy.vscode-JS-CSS-HTML-formatter#0.2.3
m-thorsen.vscode-materia#0.4.4
ms-python.python#2022.12.1
NikolaosGeorgiou.html-fmt-vscode#0.6.0
PKief.material-icon-theme#4.20.0
samuelcolvin.jinjahtml#0.17.0
streetsidesoftware.code-spell-checker#2.7.0
yzhang.markdown-all-in-one#3.5.0
zamerick.black-ocean#1.0.2
zhuangtongfa.material-theme#3.15.2
There is a bit of noise in that list. I'm not sure what all of them refer to. But for certain there is only one Python app (ms-python) and nothing related to Jupyter.
Some SO members elsewhere have suggested selecting / setting the base Python version/environment. When I click the “Select Kernel” button at the top right (as illustrated in the screenshot below), it reveals an empty menu (see at the top left):
Here is “Python v3.8.5 (conda)” showing as selected at the bottom and slightly to the left:
Another exhaustive question and answer thread elsewhere on Stack Overflow involving an issue similar to mine includes many, many creative potential solutions: jupyter server : not started, no kernel in vs code
In that Stack Overflow question, one prominent member answers:
How I solved it:
Press Command+Shift+P to open a new command pallete
Type >Python: Select Intepreter to start jupyter notebook server
Open the notebook again
Someone else suggests:
Press Command+Shift+P on mac, Ctrl+Shift+p on windows
Type Jupyter: Select Interpreter to start Jupyterserver
It would show you a dropdown of python versions installed.
I chose python 3.7.5 and it worked for me. you can choose the python version installed on your machine.
Another member says:
I have seen all possible solutions but not work, finally I just
upgrade jupyter, notebook, and jupyterlab, like pip install -U jupyterlab, and I can choose the kernel in VScode!
None of the above resolves my issue.
Here is a quirky new twist: After installing jupyterlab with pip, after restarting VSC, I encountered this weird error:
It’s a condition box. I clicked: “Yes”.
Jupyter is still not integrated properly.
UPDATED: Based on JialeDu’s answer, I followed his instructions. I created a video shared below. It doesn’t quite capture every step, but I did follow all the steps. What you can see in the gif video is that my current working directory is a folder called Test, a new terminal has been opened, and there is an active virtual environment with $ source .venv/bin/activate. Next, as you can see in the .gif, I am able to select the latest Python interpreter v3.10.5 showing as “Recommended”. So that is progress. I couldn’t do that before. Going the virtual environment route was a great idea. However, I am still not able to get the Jupyter Notebook interface as the end product shared by JialeDu. When I invoke Ctrl + Shift + P again and type > create jup a new Jupyter Notebook file is created but the kernel I selected previously does not show and the expected Jupyter interface buttons and options are still not showing. Here is the video demo in .gif formatting:
Please note: Here you can see a list of 4 available Jupyter extensions:
I avoided installing any of these separate Jupyter extensions in the store because according to the instructor (and as confirmed on the official Microsoft Python extension ms-python page which I already have), it includes Jupyter built in. From the ms-python extension entry, it explains: "This Python extension will automatically install the Pylance and Jupyter extensions to give you the best experience when working with Python files and Jupyter notebooks."
Even though other Stack Overflow users indicated that mixing the above extensions such as ms-python with ms-toolsai was a bad idea, I experimented with having them both installed anyway. Didn’t fix the issue. I tried uninstalling ms-python and keeping ms-toolsai. Still no dice.
By the way, I’ve also got the latest version (as of this writing) of VSCode v1.70.1 installed:
VS Code has prompted you to install the suggested extension. Python and Jupyter.
Also it helps to make sure your vscode is up to date.
The play button of the interface is provided by Jupyter, but if you want to run the code (select the kernel), you must also install the Python extension.
It’s a condition box. I clicked: “Yes”.
You don't have to click Yes because there is a time delay. By the time you click Yes, the environment may not be ready.
If you are using a virtual environment, you can select the virtual environment's interpreter and then create a new terminal to activate the environment.
Complete creation steps:
Prerequisites:
The machine has python installed,
and vscode has Python and Jupyter extensions installed.
steps
Create a new working folder Test
Open the folder Test with vscode
new terminal
Type the command python -m venv .venv to create a virtual environment
After the creation is complete, use the command .venv/scripts/activate to activate the virtual environment
Or Ctrl+Shift+P --> Python:Select Interpreter, select the interpreter of the virtual environment and then create a new terminal to activate the environment
Create new jupyter file using command palette command Create:New Jupyter Notebook
Or right click --> New File --> name ends with .ipynb
The virtual environment you just selected will be enabled as the kernel by default.
I discovered a very simple answer: I installed the VSC package in the official Snap repo.
VSC and Python-Jupyter look to be all playing nice together now:

VSC Updated and Broke Jupyter Notebook

I think two weeks ago, or right at the end of Feburary, VSC updated as normal. Except, in my experience, it broke the Jupyter Notebook extension, kind of. I can still open notebooks and play with them, they still connect to the kernel and run, but I can't save any new notebooks. Which is frustrating because I need to make new notebooks for my classes.
First, I'll say that I have tried to update and reinstall jupyter. By that, I mean:
pip install --upgrade notebook
pip install --upgrade jupyterlab
pip install --upgrade jupyter
Then I uninstalled VSC, and reinstalled to see if that would fix it, but the problem remains.
Here are detailed pictures of what my issue is.
I open a new file, and go to select language
Inside the languages, jupyter isn't even there
Instead I go down to open the command palette because thats where you have to open new jupyter notebooks anyway
Here you can see it says create new notebook
It does, it works as its supposed to
Then I go to save the notebook and this is totally new. It's saving it as JSON, but has the ipynb extension. Additionally, the directory I'm saving into has other notebooks in it. They don't show up with this new .ipynb.json.
It doesn't matter if I erase, leave, force the extension to be .ipynb, .json, .ipynb.json, or if I just erase it, I get this same error, and I'm not sure why.
I can't seems to get over this problem, and I'm not sure how to fix it. Let alone, what's caused this issue. Maybe somebody has had this before and worked around it, or currently has this problem?
I can not reproduce your problem, Could you try to disable all the extensions and then only enable Python-related extensions? If it still does not work, could you try to install an older version of VSCode? You can refer to here.
Change "save as type" to "All files (.)" if *.ipynb isn't a choice outright to make sure you get *.ipynb as the extension, not *.ipynb.json.

Jupyter Notbooks not launching

I'm running Python 3.8 (Anaconda) on Windows 10 and have previously not had any issues launching Jupyter Notebooks. Today that changed: When I tried to launch it from the Anaconda Navigator, it suggested that it launched it but didn't open anything in my default browser (Chrome), so nothing really happened. Also, not terminal prompt was launched. When I tried launching it from the command line, typing both jupyter notebook and jupyter-notebook it launches the notbook but only in the background (ie. it provides a link that I need to copy into my browser). I find this quite strange and am trying to understand what's going on. My hunch is that it's some kind of Windows related issue but I'd like to know what issue.
So my question is what can explain this behaviour? And assuming that this is related to some strange Windows issue, I'd be keen to find out what it is.
I replicated the exact steps I used to always launch it (which worked), so this shouldn't be anything to do with the setup.
Cheers!

Jupyter Book build fails after default create

I'm still learning how this all works, so please bear with me.
I'm running conda 4.8.5 on my Windows 10 machine. I've already installed all necessary Jupyter extensions, I think (Jupyter Lab, Jupyter Notebook, Jupyter Book, Node.js, and their dependencies).
The problem might have to do with the fact that I've installed Miniconda on a separate (D:/) drive.
I've set up a virtual environment (MyEnv) with all the packages I might need for this project. These are the steps I follow:
Launch CMD window
$ conda activate MyEnv
$ jupyter-lab --notebook-dir "Documents/Jupyter Books"
At this point a browser tab opens running Jupyter Lab
From the launcher within Jupyter Lab, open a terminal
$ cd "Documents/Jupyter Books"
$ jb create MyCoolBook
New folder with template book contents gets created in this directory (Yay!)
Without editing anything: $ jb build MyCoolBook
A folder gets added to MyCoolBook called _build, but it doesn't contain much more than a few CSS files.
The terminal throws this error traceback which wasn't very helpful to me. The issue may be obvious to an experienced user.
I am not sure how to proceed. I've reset the entire environment a few times trying to get this to work. What do you suggest? I'm considering submitting a bug report but I want to rule out the very reasonable possibility that I'm being silly.
I asked around in the Github page/forum for Jupyter Book. Turns out it's a matter of text encoding in Windows (I could have avoided this by reading deep into the documentation).
If anyone runs across this issue just know that it can be fixed by reverting to some release, Python 3.7.*, and setting an environment variable (PYTHONUTF8=1) but this is not something I would recommend because some other packages might require the default system encoding. Instead, follow the instructions in this section of the documentation.

How to make chrome compatible with Jupyter for Anaconda?

I am an anaconda user and Jupyter is a neat tool to run python code. However, for my macbook, I can't open it in Chrome (This page isn’t working
localhost didn’t send any data.),but it works in Safari, I have tried to reinstall chrome, but I still can't fix it. My system is Mac OS 10.11.5.
Who knows how I can fix it?
I can understand that the problem might be not specific enough, but I have been puzzled by this problem for quite a period of time.
There was a similar problem in the git page for Jupyter:
https://github.com/jupyter/notebook/issues/2438
Try going to directly to http://localhost:8888/tree
or whatever port you are using.
Download jupyter notebook from link below
Download jupyter notebook
Once you downloaded it, run it any browser it will work
Just copy paste the link with token from the terminal to chrome.
It should work after that.
The steps are :
Cd to directory u want to go to
Type jupyter notebook , a browser window opens up after this command.
If safari opens up copy paste the link from safari to chrome.
It might ask u for a token the first time. That can found in the terminal where jupyter command is typed.

Categories

Resources