I'm trying to write some R code in Jupyter notebooks (I use python too and would like to be able to use the same app for everything), but I'm having some problems...
I'm on a Mac (Yosemite). I installed Anaconda 3, updated Jupyter, then installed RStudio (which includes R essentials). r-irkernel is installed (I assume also through RStudio), version 0.8.11.
When I try to start an R notebook in Jupyter, it starts a kernel and then immediately it dies. The error given is:
Kernel started: 4275a83e-b2b6-40ef-b161-3a7b2ac57c43
Error: .onLoad failed in loadNamespace() for 'pbdZMQ', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Applications/anaconda3/lib/R/library/pbdZMQ/libs/pbdZMQ.so':
dlopen(/Applications/anaconda3/lib/R/library/pbdZMQ/libs/pbdZMQ.so, 6): Library not loaded: #rpath/libzmq.5.dylib
Referenced from: /Applications/anaconda3/lib/R/library/pbdZMQ/libs/pbdZMQ.so
Reason: image not found
Execution halted
What's the best way forwards, please? What am I missing?
Thanks! :)
Alex Mikhalev's answer partially worked for me. However, it also removed notebook and r-essentials.
Their answer was:
conda remove zeromq
conda install zeromq
But, I also needed to install the following as well:
conda install notebook
conda install r-essentials
Try
conda remove zeromq
conda install zeromq
worked for me.
Alas! Other answers have addressed the Anaconda methods so I address the title Jupyter notebooks for R? more generally. Anaconda is nice but always little bit behind. There is also other option to run your Jupyter R notebooks and that is Docker.
Jupyter Docker Stacks
The Jupyter Docker Stacks contains Jupyter R Notebook here available in Github and Docker hub.
You could try it with
$ docker run --rm -it -p 6780:8888 -v "$PWD":/home/jovyan/ jupyter/r-notebook
as in OS X or
$ docker run --rm -it -p 6780:8888 -v "$PWD":/tmp jupyter/r-notebook
as in some other distros or as path required to be set up by your os.
You may find the following threads useful
Show volume files in the GUI of Docker Jupyter notebook
Kernel Error in R Jupyter Notebook due to Anaconda?
Related
I have ubuntu 20.04.
I already install drake and Jupiter notebook, but
when I try python3 -m pydrake.tutorials I have got this error:
ERROR: the Jupyter notebook runtime is not installed!
Drake offers Python tutorials that can be previewed and executed as Jupyter
notebooks online with no need for local installation. To run Drake's tutorials
online, refer to the `Drake Tutorials <https://drake.mit.edu/>`_ website.
Alternatively, to run Drake's tutorials locally from an
`installed <https://drake.mit.edu/installation.html>`_ copy of Drake,
run ``python3 -m pydrake.tutorials`` to launch a Jupyter browser.
Be sure your ``PYTHONPATH`` has been set per the installation instructions,
e.g., via ``source env/bin/activate`` in the
`pip instructions <https://drake.mit.edu/pip.html>`_.
If you haven't done so already, you'll also need to install the Jupyter
notebook package on your system:
- For pip or macOS, use: ``pip install notebook``.
- For Ubuntu, use ``sudo apt-get install jupyter-notebook``.
When I try run jupyter notebook:
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/home/dmitriy/.local/lib/python3.8/site-packages/markupsafe/__init__.py)
This command helped me python -m pip install markupsafe==2.0.1.
The path /home/dmitriy/.local/lib/python3.8/site-packages/... indicates that you have local pip packages installed, but are not using a virtual environment (venv). It's likely that those packages are interfering with Jupyter's runtime environment.
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.
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 have been trying to get a Q# running for the Quantum Katas, but have been having some difficulty in finding the Q# kernal. The only kernal that shows up is the Python 3 one which is used for the Jupyter Notebook. The odd thing is that the kernal shows up when I do jupyter kernalspec list.I am using VS Code.
This is the jupyter kernelspec list
Summarizing what was said in the comments above:
First, make sure iqsharp is installed. Run dotnet iqsharp --version to ensure that the tool exists.
If not, run dotnet tool install -g Microsoft.Quantum.IQSharp to install it.
Then run dotnet iqsharp install to register the IQ# kernel in your Jupyter configuration.
If your jupyter installation still doesn't recognize the kernel, it could be a permissions issue based on how you have installed and are running Jupyter. Try dotnet iqsharp install --user instead.
As for VS Code's Jupyter implementation, currently non-Python kernels such as R, Julia, Q#, etc. are not supported. This GitHub issue tracks adding support: https://github.com/microsoft/vscode-python/issues/8521
I am new to jupyter/ipython. I usually start the notebook on a remote machine and create a ssh tunnel. Details of how the tunnel is set up can be found here: http://www.hydro.washington.edu/~jhamman/hydro-logic/blog/2013/10/04/pybook-remote/
However, many times when I start a notebook, it reports back with 0 active kernels (not all the times). Following is the screenshot of that:
-bash-4.1$ jupyter notebook --no-browser --port=7777
[NotebookApp] Serving notebooks from local directory: /x/y/z
[NotebookApp] 0 active kernels
[NotebookApp] The Jupyter Notebook is running at: http://localhost:7777/
[NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
I obviously have python.
python --version
Python 2.7.11 :: Anaconda 2.0.1 (64-bit)
Can someone explain to me this erratic behavior? and how it can be fixed?
Any help would be appreciated.
Thank you
Attached is the error I get:
I also use jupyter using a ssh tunnel and was getting 0 active kernels message and I could not run any notebook. My error snapshot is here. The ipython kernel was not installed properly in the direct install of jupyter using sudo -H pip install jupyter. I resolved it by updating the ipython kernel using:
sudo apt-get -y install ipython ipython-notebook
sudo -H pip install jupyter
If it doesn't work, try uninstalling jupyter and then install packages in sequence as explained in this link.