Unable to run jupyter notebook inside google colab code - python

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?

Related

Jupyter notebook won't launch after writing "jupyter notebook" in terminal

I have been searching this problem since a while, but can't find a solution. I am working in Windows 10.
After I activate any virtual environment and I write "jupyter notebook", the terminal gets stucked and nothing happens, like in the picture:
No errors appear, I can't Ctrl+C to kill terminal and no browser page appears.
The "jupyter --help" command works, but any other subcommand (like jupyter lab, jupyter nbclassic or jupyter run) doesn't
I tried to do the following, with no results:
Uninstall and install jupyter again
I tried to lunch jupyter notebook with Anaconda Navigator
I tried to open a browser and go to "http://localhost:8889/tree", using different port values
I tried to restart my laptop
Does anyone have any idea what is going on?
Well,
If you've re-installed Anaconda with the default settings, it should set up PATH correctly. So I hope the error is not with PATH environment variable
Try the following:
If Jupyter gives an error that it can’t find notebook, check with pip or conda that the notebook package is installed.
Try running jupyter-notebook (with a hyphen). This should normally be the same as jupyter notebook (with a space), but if there’s any difference, the version with the hyphen is the ‘real’ launcher, and the other one wraps that.
It turned out that jupyter notebook was not starting because I could not ping my localhost (127.0.0.1) because of some bad network settings.
After running netsh winsock reset in a cmd terminal to reset the network settings, I could ping the localhost and jupyter notebook started to work again.

VSCode GitHub remote repository with Python Notebook Local Kernel

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.

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

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

PyCharm Jupyter notebook : Add Jupyter to the interpreter of the current project

I have a new project in PyCharm under it the project, I create a jupyter notebook
but when I run it I keep getting this error
Add Jupyter to the interpreter of the current project.
I cant figure out what to do, I have reset the
Project Interpretor
But no use
You need to install jupyter for the project interpreter or the virtualenv that you use:
pip install jupyter
PyCharm support for the Jupyter Notebook is shaky IMO. You will probably need to restart it, and respond to dialog windows trying to connect to the default Notebook server location, localhost:8888. On my machine, canceling that request to connect strangely helps to finally see the output of the cells within PyCharm.

Categories