VSCode GitHub remote repository with Python Notebook Local Kernel - python

Has anyone managed to run an ipynb Python notebook using a local kernel but connecting to a remote GitHub repository using the GitHub Repositories extenstion.
I can open the ipynb file directly from the GitHub repo but cannot connect to a kernel because it doesn't seem to find the local cached version of the notebook to run.
Error message:
[C 10:22:20.876 NotebookApp] Bad config encountered during initialization: No such notebook dir: ''/githubuser/reponame''
Using:
MacOS
VSC 1.66
GitHub Repositories extension v0.28.0
Tried multiple Python kernels.
Anyone got any ideas?

I am using windows, and it works well on my side. I think this extension works well with the local python environment.
The problem you have run across looks like the problem of jupyter configuration. You can execute jupyter --paths to get the jupyter configuration path. It should be “/Users/UserName/.jupyter/jupyter_notebook_config.py” on the MacOs. You can refer to here for the details of jupyter_notebook_config.py.
Then you need to modify c.NotebookApp.notebook_dir = to a existing path or just comment it.

Related

Unable to run jupyter notebook inside google colab code

I wanted to run jupyter notebook inside vscode inside virtual environment running in google colab.
I have installed vscode server inside google colab, mounted google drive to it and accessing vscode in browser with ngrok as made possible colabcode. You can run cells of this notebook to boot up yours. In the end, this notebook gives a link to <unique-environment-id>.ngrok.io. Opening it gives you vscode running in browser and connected to google colab VM as well as google drive.
Then I installed pipenv with command pip install pipenv in vscode's terminal.
Then I created virtual environment using pipenv and was able to use it as can be seen in below snap:
Now I wanted to run jupyter notebook inside vscode against this environment. When I opened jupyter notebook and executed the cell, it showed me following error:
Then I followed solutions given here:
pipenv install traitlets==4.3.3
But now re-running the same cell gives me following error:
Failed to start the Kernel.
[IPKernelApp] CRITICAL | Bad config encountered during initialization:
[IPKernelApp] CRITICAL | The 'kernel_class' trait of <ipykernel.kernelapp.IPKernelApp object at 0x7f54f007b290> instance must be a type, but 'google.colab._kernel.Kernel' could not be imported.
How do I fix this?

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)

Error loading Jupyter Notebook from a child directory

Since I have updated to macOS Big Sur (I have managed to fix all of the Python issues that Big Sur created on my computer. This article is helpful for that), I've been unable to open the Jupyter Notebooks in any of the child directories of where I start my Jupyter Notebook.
I can however open notebooks in the same directory as where I had started my Jupyter Notebook instance.
Here is a screenshot of the error message:
Here also is the error message I get in the terminal when trying to open a new notebook in a child directory:
[W 20:18:51.458 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20210723201825 (::1) 2.560000ms referer=http://localhost:8888/notebooks/0001_analysis/Untitled2.ipynb?kernel_name=python3
I use pyenv and poetry to manage my python environment and packages. I have the local version of python set to Python 3.8.2.
Here are my poetry dependencies in my pyproject.toml:
[tool.poetry.dependencies]
python = "^3.8
[tool.poetry.dev-dependencies]
pandas = "^1.3.0"
scikit-learn = "^0.24.2"
jupyter = "^1.0.0"
seaborn = "^0.11.1"
ipykernel = "^6.0.1"
Would be great to fix this, as it is inconvenient having to create new notebook instances when I need to open notebooks in different child directories of my project.
This may be system integrity protection, though I've seen it in Catalina before, did you leapfrog a version ?
If you are starting Jupyter from the terminal, try the following:
Open a new terminal, , type cd (with a space) and drag and drop the folder you wish to start jupyter in to the terminal. You need to drag and drop, this will flag the folder as being "ok to be accessed from application launched from the terminal" typing the path by hand won't help. Press enter, and then try to start jupyter from there.
If you have any error message in the terminal they should be helpful, try to also open the .ipynb files with a text editor to make sure they are not corrupted, and/or share them with somebody else to see if they can open it.

Why is Jupyter notebook 'pointing' at old repo location?

I've recently moved the location of my git repo. All my standard Python scripts work just fine but for some reason my Jupyter notebooks can't even import any modules. I've re-cloned my repo to the original location and the notebooks run fine again.
I've tried searching the VS Code settings for something that resembles a working directory for Jupyter but no luck. Any ideas on what might be going on and how I could fix it?
For reference:
OS: Windows 10
VS Code: 1.53.2
Python extension: 2021.1.502429796
Jupyter extension: 2020.12.414227025
Edit:
I've been able to put a sticking plaster on this by using os.chdir() to select the new repo.

Internal Server Error in Jupyter Notebook

I'm working with jupyter notebook through SSH (anaconda and python are on my linux machine but output in jupyter notebook I see on windows machine).
I tried to install keras and tensorflow but something went wrong and I removed these packages. After that I can't open any of my notebooks (but the file system output is okay, I can see all the folders and files in jupyter notebook).
Can you please help me to solve it? I think maybe it happened when tensorflow was removed, some packages also were deleted?

Categories