Anaconda-Jupyter Doesn't open in browser - python

I installed Anaconda 3.7 on Ubuntu 18.04 (Bionic Beaver). Installation was successful. When I tried to start Jupyter Notebook from navigator it throws the following error.
Access to the file was denied The file at
file:///run/user/1000/jupyter/nbserver-26395-open.html is not
readable. It may have been removed, moved or file permissions may be
preventing access.

For me, this worked on Raspberry Pi4, Ubuntu 20.04, with Chromium Browser.
Generate the config file with following command.
jupyter notebook --generate-config
Config file is created at ~/.jupyter directory
Look for parameter c.NotebookApp.use_redirect_file and set the same as False.
c.NotebookApp.use_redirect_file = False in order to disable launching browser by redirect file .
Explanation:
For versions of notebook > 5.7.2, a security feature measure was added
that prevented the authentication token used to launch the browser
from being visible. This feature makes it difficult for other users on
a multi-user system from running code in your Jupyter session as you.
However, some environments (like Windows Subsystem for Linux (WSL) and
Chromebooks), launching a browser using a redirect file can lead the
browser failing to load. This is because of the difference in file
structures/paths between the runtime and the browser.
Also make sure the ~/.local/share/jupyter and ~/.jupyter directories are owned by the user running jupyter

I think you have changed your default browser from Firefox to something else, Jupyter Notebook works fine on Firefox but throws permission denied on Chromium (for me). Just go to Setting > Details > Default Application and select FireFox in Web. Cheers

As shown in the image, jupyter notebook also provides a link. Try opening it with the browser of your choice. It worked for me...

With recent versions of snap, applications installed with snap can't by default open files in hidden folders (with a name starting by .).
In Ubuntu 20.04, chromium is installed with snap (even when using the command sudo apt install chromium-browser), so chromium can't open the html file used by Jupyter.
As stated by #rahul-sood, a simple workaround is to copy-paste one of the alternative links given by Jupyter in the terminal (starting by http://localhost:8889/?token= or http://127.0.0.1:8889/?token=).

For anyone interested in open jupyterlab or jupyter notebook in chrome : install it in the terminal with
sudo apt-get install google-chrome-stable
It didn't work for me by using chromium. And, as mentionned paugier, in Ubuntu 20.04, chromium is installed with snap (even when using the command sudo apt install chromium-browser), so chromium can't open the html file used by Jupyter. So if you install chrome by using the terminal it works.

Open Chrome and paste the Jupiter file path. In my case it's file:///home/vanx/.local/share/jupyter/runtime/nbserver-14511-open.html and it worked.

Related

Jupyter Notebook: Access to the file was denied

I'm trying to run a Jupyter notebook on Ubuntu 21.10. I've installed python, jupyter notebook, and all the various prerequisites. I added export PATH=$PATH:~/.local/bin to my bashrc so that the command jupyter notebook would be operational from the terminal.
When I call jupyter notebook from the terminal, I get the following error message from my browser:
Access to the file was denied.
The file at /home/username/.local/share/jupyter/runtime/nbserver-260094-open.html is not readable.
It may have been removed, moved, or file permissions may be preventing access.
I'm using the latest version of FireFox.
I've read a number of guides on this and it seems to be a permissions error, but none of the guides that I've used have resolved the issue. Using sudo does not help, in fact it causes Exception: Jupyter command "jupyter-notebook" not found. to be thrown.
That being said, I am still able to access the notebook server. If I go to the terminal and instead click on the localhost:8888 or IP address of the notebook server then it takes me to the notebook and everything runs without issue.
I would like to solve this so that when I run jupyter notebook I'm taken to the server and don't need to go back to the terminal window and click the IP address. It's inconvenient and can slow me down if I'm running multiple notebooks at once.
Any help on this issue would be greatly appreciated!
I had the same problem.
Ubuntu 20.04.3 LTS
Chromium Version 96.0.4664.110
This was the solution in my case:
Create the configuration file with this command:
jupyter notebook --generate-config
Edit the configuration file ~/.jupyter/jupyter_notebook_config.py and set:
c.NotebookApp.use_redirect_file = False
Make sure that this configuration parameter starts at the beginning of the line. If you leave one space at the beginning of the line, you will get the message that access to the file was denied.
Otherwise you can clean and reinstall JupyterLab
jupyter lab clean --all
pip3 install jupyterlab --force-reinstall
If anyone is curious, the reason for the problem is that the file:// URI scheme cannot access files in hidden directories directly under the home directory (~/.local in your case).
You can recreate the problem with:
mkdir ~/.test && echo "abc" > ~/.test/file.html && xdg-open ~/.test/file.html
I couldn't find any reference for this behaviour in RFC8089, and I also don't understand how the Jupyter authors missed this issue.
As LSeu suggested, the way to bypass the local redirection file, is to run:
echo "c.NotebookApp.use_redirect_file = False" >> ~/.jupyter/jupyter_notebook_config.py
Another solution is to run jupyter notebook --no-browser and (Ctrl)-click the link in the terminal.
For those running Firefox installed with snap:
I think this issue has more to do with firefox installed with Snap, which somewhere along the way disallows Firefox access to hidden directories inside the /home/user folder in its sandboxed environment.
Another solution not mentioned in this thread (if you don't want to use another browser install) is to set the JUPYTER_RUNTIME_DIR env variable to a non-hidden directory in the /home/user folder:
# Ubuntu 22.04.1 LTS
# append env variable to persistent user env file. requires relogging in
echo JUPYTER_RUNTIME_DIR=/home/user/jupyter_runtime >> ~/.pam_environment
reboot
Alternatively, try going directly to the other suggested URLs: http://localhost:8888/lab?token=<your-access-token> or http://127.0.0.1:8888/lab?token=<your-access-token> (which is what setting the ...use_redirect_file = False does)

Just installed Jupyter using Anaconda but can't run it using terminal. Says command not found

I just bought my very first Mac after using Windows my entire life and have been trying to install things. I am also still kind of a beginner at programming.
I installed Anaconda for Python 2.7 version, and then I installed the 3.7 version right after.
I tried going to terminal and typing jupyter notebook but it says:
zsh: command not found: jupyter
I am able to launch a jupyter notebook (I think) when I search for jupyter notebook in spotlight and executing the top hit.
I've been reading a lot on forums about this issue and see a lot of people talking about PATH which I am not really sure about.
I've seen people also post their which python information and theirs seem very different from mine:
which python3
usr/bin/python3
which python
usr/bin/python
Any help would be appreciated! Still learning how to set up this Mac. Thank you.
You might want to refer to this link https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html
3.1.2. Change Jupyter Notebook startup folder (Mac OS)
To launch Jupyter Notebook App:
Click on spotlight, type terminal to open a terminal window.
Enter the startup folder by typing cd /some_folder_name.
Type jupyter notebook to launch the Jupyter Notebook App The notebook interface will appear in a new browser window or tab.
From what I can understand you are not changing to the startup directory of Jupyter.
You need to add jupyter to your path.
In your terminal, type in the following command:
export PATH="/PUT JUPYTER PATH HERE:$PATH"
Then try jupyter notebook
Reasoning: If installing using pip install --user, you must add the user-level bin directory to your PATH environment variable in order to launch jupyter lab

Why does jupyter notebook server keeps crashing when .ipynb files are opened?

I was able to use jupyter notebook 4 days ago. The only thing that changed was there was a firefox version update.
After that the server crashes everytime .ipynb files are opened. Even the directory will have a server error. I tried it both on Firefox and Google Chrome, both browsers will crash the server.
My only kernel is python3 and it always says "Kernel Busy". I tried resetting my pc and the jupyter notebook, but nothing seems to work.
The console showed:
The last 2 lines are causing the crash but I don't know how to fix it
When I type conda install jupyter in the anaconda prompt, I get something before it finishes as shown below. Maybe it might have a cause as to why it is having issues:
I created a new python environment and installed python, matplotlib, pandas, jupyter and it still crashes
Please uninstall and re-install all the below items:
ipykernel
ipython
jupyter_client
jupyter_core
traitlets
ipython_genutils
Additionally, if you're going to install with conda, follow below command.
run conda clean -tipsy
This command will clean up conda caches before you start.
Reference:
https://github.com/jupyter/notebook/issues/1892
Do you let Jupyter start the browser? If so, disable that and start the browser manually. I don't see how the zmq error messages could be related to the browser startup, but since you say that the only change was a browser update, that's worth a shot.
Check which version of pyzmq is installed. If Jupyter Notebook and the kernel are in different conda envs, check both and make sure they are on the same version and build. Try upgrading or downgrading to different versions. According to Anaconda issue 8932, there are problems with pyzmq on Windows. And a new build for win32 was released about two weeks ago - though I would expect win64 builds to be used nowadays.
I also found some recommendations for a similar error message to yours in Spyder issue 6097. The first one is to try without firewall and/or antivirus. You might have picked up a new firewall rule unknowingly. Trying different versions of pyzmq is also mentioned there.
I am sharing this solution in case someone needs it in the future.
I have just faced the same problem a hour ago. This was the message I was getting in the terminal. And the jupyter keeps restarting.
ModuleNotFoundError: No module named 'html.entities'; 'html' is not a package
[I 00:44:32.436 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
After Searching through the internet when I can not find the solution. I fixed it by removing the .HTML files I had in the directory. After moving those file jupyter started working parfectly.
I just had a similar problem - for me, it was casued by a non-existing %temp% directory (I have %temp% mapped to a ram disk, and the temp folder on it wasn't created yet).
Creating the folder pointed to by %temp% solved the issue.
All my environments were working totally fine but suddenly after restarting the system, the jupyter notebook from an environment was not opening or it was suddenly crashing. Tried form anaconda prompt but getting "Unable to create Process...
All my DL dependencies were on this environment and I didn't want to create new environment completely installing all the required dependencies.
Solution: I opened the Anaconda Navigator and cloned old_env to new_env and it worked magically. I could able to open the jupyter notebook successfully and all dependencies were working fine. Hope it helps

Pycharm jupyter notebook wsl: Jupyter package is not installed

I would like to use Jupyter notebook inside Pycharm. The project interpreter is a python2.7 from a virtual environment inside WSL (ubuntu 18.04).
The Jupiter package is correctly installed inside the virtual environment (I can run it by jupyter notebook).
My problem is that when I want to use Jupyter notebook inside Pycharm, I get the following error: Run Error Jupyter package is not installed (see picture).
Any idea what's going on here?
I had this problem in Python 3. Below are the steps I took to resolve the issue; I believe they should resolve the issue for you too:
I had Jupyter Lab installed. Pycharm only works with Jupyter Notebook. Long story short, if you have Jupyter Lab installed you need to uninstall all your packages using:
$ pip freeze | xargs pip uninstall -y
Restart your computer
Follow Jupyter Notebook installation instructions
Make sure WSL is set up through pycharm instructions: wsl pycharm instructions
In Pycharm, open an .ipynb file. Click the dropdown that says "Managed Jupyter server" It's right above the text editor. Select "configure Jupyter server". Check configured server.
In your wsl terminal, type jupyter notebook. Copy and paste the text that looks like: http://localhost:8888/?token=874asdf687asd6fasd8f74ds6f4s9d8f7sddf into the cofigured server box in Pycharm.
That's it. You should be able to run the jupyter cells in pycharm now.
I have Pycharm 2020.3 For me the issue was I was using a virtual environment with "inherit global site packages." I had Jupyter installed in global site packages but NOT the virtual environment.
Once I installed Jupyter within the virtual environment Jupyter notebook worked. Not sure why inheriting Jupyter from global packages wasn't working for me.
The above solution using a designated url with token seems to work with older versions of PyCharm. A simpler solution is to upgrade to the latest PyCharm. I no longer had an issue with the auto server using PyCharm 2019.3.2 (Mac)
I had this problem with Datalore plugin enabled on 2020.2 linux, running on bare metal but displaying to a remote X server (probably doesn't matter). My solution was to disable the Datalore plugin (it's enabled for professional pycharm by default).
This way I was still able to use the "managed" auto-start version with better integration / debugging vs the "configured" option (or at least with less hassle).
Note since it's been a year, my problem is probably different than OP.
This happened for me, when the interpreter was a remote one. I fixed this by changing the interpreter to one from a local env.
This can be done by selecting the Configure Jupyter Server.
I also meet this problem,and i solved it
i create the new project with the global sit-packages like below
then i meet the problem
i create the new project with no global sit-packages and install jupyter notebook in the virtualenv
then the problem is gone

ipython notebook can't open web browser

system:CentOS release 6.4 (Final)
python: 2.7.11
ipython:IPython 4.2.0
jupyter : 4.1.0
I tried to run IPython notebook. But after typing the command "ipython notebook", i found it didn't open the web browser, whereas still staying on the Linux like the picture below showing:
enter image description here
I have the similar problem with you before. I fixed it by adding a default browser in my ubuntu subsystem.
$ sudo apt-get install firefox
Then I using Xming X server to configure graphical application under my subsystem can be displayed using bash. To do that, simply install Xming, and then go to ~/.bashrc file add the following lines:
export DISPLAY=:0
After saving, you should be able to run firefox by typing:
$ firefox
Then, run
$ jupyter notebook
It should pop up a web browser and open jupyter notebook.

Categories