I am trying to open Jupyter Notebook from Ubuntu terminal, but it fails to start because of permission issues. Specifically, a webpage would open up in the Firefox browser, which displays the error message
The file at /home/<user>/.local/share/jupyter/runtime/nbserver-61219-open.html is not readable.
I have found an similar issue at Cannot open new Jupyter Notebook [Permission Denied], which suggests that I should change the ownership of the folder by typing the command
sudo chown -R <user>:<user> ~/.local/share/jupyter
However, this did not work for me. I have also tried other suggestions from https://github.com/microsoft/WSL/issues/3608. The commands sudo jupyter-notebook --allow-root or sudo jupyter notebook --allow-root result in errors saying that the commands are not found. I have also tried chmod -R 777 <my directory>, and the same error still occur.
I realize that at runtime, Jupyter Notebook produces a .html file and a .json file in /home/<user>/.local/share/jupyter/runtime/, the directory where the permission error is reported. By running ls -l on this directory during runtime, it seems like I (both the user and the group) do not have execute permission on these two files, but have read and write permissions. Is this the cause to my problem? How can I fix this?
(Additionally, I installed Jupyter Notebook using pip inside the conda base environment, and all the above commands are executed in the same environment)
Specs:
Ubuntu version: 21.10
Jupyter Notebook version: 6.4.5
Miniconda version: 4.10.3
Python version: 3.9.5
Web browser: Firefox
Try changing the version of the Jupyter Notebook installed. It worked for me (I am using Ubuntu 22.04 pre release).
Type the following in terminal: pip install notebook==5.6.0
Ubuntu switched Firefox to a snap in 21.10. Snaps can't open files under directories that are hidden in your home directory, like ~/.local.
I have the same issue and am hoping for a solution less drastic than removing the snap and reinstalling Firefox using apt.
Related
I bought Macbook air M1, and I tried to install jupyter notebook with this code.
pip3 install --upgrade pip
pip3 install jupyter
and I tried to open jupyter notebook with this code.
jupyter notebook
but, then, this code appeared.
zsh: command not found: jupyter
enter image description here
First, you need to find where it was installed.
pip3 show jupyter | grep Location
Example:
$ pip3 show pip | grep Location
Location: /usr/lib/python3/dist-packages
Then you need to ensure that the path you get is in your PATH.
Example:
$ export PATH=/usr/lib/python3/dist-packages:$PATH
Try adding Python's bin/ folder path to $PATH variable.
You should be able to find it here - /Users/<your-username>/Library/Python/3.x/bin
Step 1 : Open .bash_profile in text editor
open ~/.bash_profile
Step 2 : Add the following line at the end of the file
export PATH="/Users/<your-username>/Library/Python/3.x/bin:$PATH"
Step 3 : Save the edits made to .bash_profile and restart the terminal
This issue and many others are bound to happen with Jupyter. There are many tools that install Jupyter and they all do it a bit differently.
To sidestep the whole problem of clunky installs, try a desktop "click and run" app for Jupyter.
For macOS and iOS, that's Callisto. It's currently in the beta stage so you can try it out for free (it even lets you connect to cloud servers for running your notebooks!)
For reference: This comment has a good solution for fixing pip3 install on macOS
Good luck!
I've hit a dead end trying to solve/debug this issue which doesn't seem like it should be that difficult.
I'm working in Pycharm IDE (not the professional) and I'm working inside a virtual environment let's call it pythonProject and I want to be able to run launch a jupyter notebook in this environment so that it can pick up all the python packages i've installed and configured for this environment.
As I understand it from the documentation, these are the steps I need to take.
My terminal prompt statement:
(pythonProject) oliver#oliver-u20:~/pythonProject$
commands:
python3 -m pip install ipykernel
python3 -m pip install notebook
python3 -m ipykernel install --user --name pythonProject --display-name "Python (pythonProject)"
jupyter notebook
But when I load jupyter notebook, it only shows python3 under kernels.
I tried outputting
jupyter kernelspec list
And get only the base kernel which suggests from this that it's not finding my kernelspec, but I can't seem to figure from the documentation what i'm supposed to do.
Am I missing something?
Ok so I've solved this.
I think there was an install issue with jupyter.
I tried reproducing this in a completely new project and venv and could get the kernel showing.
In the project and venv where I still couldn't, I noticed a discrepancy in the output of my jupyter --paths
In the working venv I could see under data
/home/oliver/.local/share/jupyter
Which is where the kernels I installed are located.
However in the project that wasn't working there was instead:
/home/oliver/snap/jupyter/6/.local/share/jupyter
I'm guessing this snap path is from how I originally installed jupyter on my Ubuntu via the app store - seemed sensible at the time.
So I uninstalled jupyter, restarted my venv and the jupyter --paths has magically changed so that
/home/oliver/.local/share/jupyter
is present and when I start a jupyter notebook at the command line with
jupyter notebook
I can see all my kernels showing!
I found this quite difficult to debug with the documentation and command help outputs so hope someone else finds this useful.
I just updated my macOS to Catalina and I can't run python or open a jupyter notebook from terminal anymore. As an example, I get error message "ImportError: No module named pandas" when running my python code, and I get
zsh: command not found: jupyter
when running
jupyter notebook
This issue has brought me to anaconda (I would love someone to explain me why. Does python need anaconda to be ran?). I have tried several suggestions from https://github.com/ContinuumIO/anaconda-issues/issues/10998, e.g. I have tried copying folder "anaconda3" from "Relocated items" folder to "Users//", then
export PATH=''/Users/<username>/anaconda3/bin:$PATH"
but I get either
dquote>
or
zsh: /Users//Applications/anaconda3/bin/conda: bad interpreter: /anaconda3/bin/python: no such file or directory
I then tried to reinstall Anaconda using the graphic installer (from https://www.anaconda.com/distribution/#macos) following advice from someone from the anaconda team (https://www.anaconda.com/how-to-restore-anaconda-after-macos-catalina-update/) (I changed installation location to a folder I created in /Users//) but I still get the same error messages when running python3 or jupyter notebook.
How can successfully run python and jupyter notebook with macOS Catalina?
After installed macOS Catalina, we can switch the terminal from bash to zsh. There are many advantages from using zsh instead of bash, but One of the issues with zsh is some of the frameworks (jupyter notebook,conda) are not supported directly. Once I typed jupyter notebook in terminal to run it. It displayed “zsh: no such file or directory”.
The solver is simple but very difficult to find online.
If jupyter was already installed before the update and stopped working after zsh, you should be able to fix it by:
1.open zshrc in terminal by typing: open .zshrc or $open .zschrc
2. add the following line at the end of the file:
source ~/.bash_profile
It will ask zsh to use all the information from bash like the path of jupyter.
Hope it can help you out!
I'm answering to my own question in case it can help others ;)
I found my answer here: https://medium.com/#singhaniatanay18/mac-os-catalina-update-zsh-instead-of-bash-d688f68f70b8
(see comments as well)
Mac OS BigSur:
Uninstall Anaconda:rm -f Anaconda-Navigator.app
re-install pip3 install jupyterlab
I just updated to Catalina, two days before Big Sur release.. oh well.
Catalina came with changes to security and bash, that will remain for future releases. So Catalina moves your anaconda3 folder to /Users/Shared/Previously Relocated Items/Security/anaconda3 I tried to move it back to home directory, but that didn't work. So I deleted it, and reinstalled Anaconda using the command line installer Not the GUI installer, and it worked for me. You can follow instructions here and use /Users/me/anaconda3 folder as recommended here.
Here are the commands that worked for me,
shasum -a 256 /Users/username/anaconda3 . Although not sure it did anything
bash ~/Downloads/Anaconda3-2020.02-MacOSX-x86_64.sh or whatever the name of the command line installer from Conda in your Download folder, or wherever else you downloaded it.
Use sudo in front of the command if permission was denied, then enter your log in password for your Mac
source /Users/username/anaconda3/bin/activate conda init zsh
sudo conda init zsh then enter your Mac's password.
You should be all set now, and all commands like ipython, conda info, jupyter notebook, pyspark will all work.
The last command will make step3 command persist i.e. initialize conda base environment, such that you can run conda, ipython, jupyter notebook the next time you use terminal.
Install the Jupyter using Homebrew in zsh shell
If you don't Python install 3.3or higher.
Open terminal
Using Homewbrew install jupyter
brew install jupyter
Now, you start a notebook
jupyter notebook
Whenever I try to export a Jupyter notebook as a PDF I get the following error in a separate window:
500 : Internal Server Error
The error was:
nbconvert failed: xelatex not found on PATH, if you have not installed xelatex you may need to do so. Find further instructions at https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.
I am running macOS Sierra 10.12.6.
Things I have tried:
Re-installing nbconvert through pip (in the Jupyter notebook) and conda (terminal)
Installing xelatex for Mac
Re-installing Mactex
Installing pandoc (both through pip and through "conda install -c conda-forge pandoc")
Running
!echo $PATH
Yields:
/Users/ed/anaconda/bin:/Users/ed/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin
I located the directory containing xelatex as per #einsweniger suggestion here: /usr/local/texlive/bin/x86_64-darwin. I copied and pasted XeLatex into the bin directory above, and get a new error:
nbconvert failed: PDF creating failed, captured latex output:
warning: kpathsea: configuration file texmf.cnf not found in these directories: /Users/e/anaconda/bin:/Users/ed/anaconda/bin/share/texmf-local/web2c:/Users/ed/anaconda/bin/share/texmf-dist/web2c:/Users/ed/anaconda/bin/share/texmf/web2c:/Users/ed/anaconda/bin/texmf-local/web2c:/Users/ed/anaconda/bin/texmf-dist/web2c:/Users/ed/anaconda/bin/texmf/web2c:/Users/ed/anaconda:/Users/edefilippis/anaconda/share/texmf-local/web2c:/Users/e/anaconda/share/texmf-dist/web2c:/Users/ed/anaconda/share/texmf/web2c:/Users/ed/anaconda/texmf-
This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018) (preloaded format=xelatex)
kpathsea: Running mktexfmt xelatex.fmt
I can't find the format file `xelatex.fmt'!
I also put xelatex.fmt in the directory, but am still getting the error.
I encountered the same issue. As people previously stated, the problem lies in that xlatex isn't found in your PATH environment variable.
A solution that worked for me was to run the following from the notebook:
!export PATH=/Library/TeX/texbin:$PATH
Or in a command line simply:
export PATH=/Library/TeX/texbin:$PATH
And then run the export to pdf from a command line (within your virtual environment if there is one in place) as follows:
jupyter nbconvert your_notebook.ipynb --to pdf
This should create a pdf of your notebook on the same directory it is running.
$ sudo apt-get install texlive-xetex texlive-fonts-recommended texlive-plain-generic
I'm not accustomed with Mac install paths, from what the basictex faq says, I gather the executeables should live in /usr/local/texlive/bin/x86_64-darwin
Running which xelatex in a terminal might also help finding where the command is, but that only works if the directory is already in your PATH variable.
Another method would be running find / -name 'xelatex' if it is not within your PATH so you might find it that way (might take a while as this will search you whole harddrive).
Once you've found it and added the path to your PATH variable, you should also check if the jupyter has the correct PATH by running
import os
print(os.environ['PATH'])
within a notebook.
On mac, you can install mactex using homebrew with the following: brew install --cask mactex
I know this question is long answered, but I just ran into this issue and found a very easy, codeless solution: print to PDF.
Thought I might post this here for anyone else who doesn't feel like figuring out path variables or updating a zillion different things. Your browser's print function probably works just fine.
I've run into similar issues in the past with paths in python when using tensorflow in Windows and Linux. As is pointed out by others, using PATH is the way to go (i.e update in .bashrc if it was linux), but I've found the code below to resolve path issues on a script by script basis.
import sys
if "\your\path\to\xelatex" not in sys.path:
print('adding path') # I just add this to know if the path was present or not.
sys.path.append("\your\path\to\xelatex")
essentially would check PATH for what it is you are looking for and then adds it if it is missing. You probably don't even need the 'if' statement.
Perhaps not the most practical way has worked well for me where I know the path in question is perhaps a 'rarely used' or 'one time use' PATH add...
So as was pointed out in comments above (and I think you already have) find the location of the file and add its location using the above code.
Some more reading on it:
https://docs.python.org/3/tutorial/modules.html
6.2 Standard Modules
If (You are using jupyter the easier way I found was to)
Download the file in latex.
Upload it to overleaf.
And then download it as a pdf
Else if ( You are using google collab)
Download as ipynb
Upload to jupyter and repeat the above steps.
Windows users can save the .ipynb file as a HTML file and print the HTML file to save it as PDF with custom settings.
If there is an update available maybe try and update Jupyter
Add "env": {"PATH":"$PATH"} to your kernel.json, for me that was in /opt/anaconda3/share/jupyter/kernels/python3/kernel.json.
JupyterLab or Anaconda seems to override the system PATH by default, if you set this then the PATH will be the same in JupyterLab and in your shell, so if you have anything custom installed like xelatex, it will show up in JupyterLab.
Run this command in your jupyter terminal (or in your environment if you have any), close all jupyter notebook tabs and reopen it then convert the notebook to pdf
pip install --upgrade --user nbconvert
How to install latex and xelatex on Mac so that Jupyter "Download as PDF" will work
brew install pandoc
brew tap homebrew/cask
brew cask install basictex
eval "$(/usr/libexec/path_helper)"
# Update $PATH to include `/usr/local/texlive/2020basic/bin/x86_64-darwin`
sudo tlmgr update --self
sudo tlmgr install texliveonfly
sudo tlmgr install xelatex
sudo tlmgr install adjustbox
sudo tlmgr install tcolorbox
sudo tlmgr install collectbox
sudo tlmgr install ucs
sudo tlmgr install environ
sudo tlmgr install trimspaces
sudo tlmgr install titling
sudo tlmgr install enumitem
sudo tlmgr install rsfs
More info here
Close all the anaconda runing programs and then,open conda command prompt and try the following command:
conda install -c conda-forge pandoc
Update/Reinstall Anaconda if not updated.
now install chromium through link https://chromium.woolyss.com/download/en/ and make it default browser.
Then run jupyter notebook using this browser.
Lastly use option "Download as" in jupyter notebook and then select the option using PDF via pyppeteer (.html)
HOLA!! It worked..
I installed Jupyter Lab but cannot launch it (jupyter lab) due to the error: Error executing Jupyter command 'lab': [Errno 2] No such file or directory.
However, it is installed, and is show as one of available subcommands (via jupyter lab):
Available subcommands: bundlerextension console kernelspec lab labextension
labhub migrate nbconvert nbextension notebook qtconsole run serverextension
troubleshoot trust
Why does it not work and is there something I'm missing here? jupyter notebook works without any problems. I also added jupyter serverextension enable --py jupyterlab --sys-prefix according to the documentation on Github, FYI.
My working environment:
jupyter notebook --version # 5.0.0
jupyter version # 4.3.0
#Blazard open the .profile in your home using VIM add the following path
export PATH=$PATH:/home/<user-name>/.local/bin
save it
$ source ~/.profile (Dont forget to do this)
I had the same problem. Installing it over PyCharm IDE solved the problem for me. I am using Windows as an OS. Installing packages over PyCharm works in general better for me than over Windows cmd.
#Blaszard could you try the following
/home/<your-user-name>/.local/bin/jupyter-lab
SOURCE
EDIT
Alternatively, you would have to add /home/<your-user-name>/.local/bin to your PATH variable. However, you should probably just try it manually first and see if that even works at all.
simple solution I found for my mac powerbook is:
go to a working directory in the terminal and then type jupyter lab.
IT WORKS,
We need to find jupyter-lab command. In my case on a mac it is in /opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/.
I'm using macports so my binaries are in /opt/local/bin. It's on my path:
> echo $PATH
.../opt/local/bin...
I have to create a symbolic link in this directory:
ln -s /opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/jupyter-lab jupyter-lab