vscode jupyter notebook: Session cannot genreate requests - python

I've been using vscode with Jupyter notebook extension (now maintain by Microsoft) for two years but It's weird to encouter the problem never met before as the error said:
Error: Session cannot generate requests
at S.executeCodeCell (c:\Users\alex0\.vscode\extensions\ms-toolsai.jupyter-2021.10.1101450599\out\client\extension.js:66:301742)
at S.execute (c:\Users\alex0\.vscode\extensions\ms-toolsai.jupyter-2021.10.1101450599\out\client\extension.js:66:300732)
at S.start (c:\Users\alex0\.vscode\extensions\ms-toolsai.jupyter-2021.10.1101450599\out\client\extension.js:66:296408)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at t.CellExecutionQueue.executeQueuedCells (c:\Users\alex0\.vscode\extensions\ms-toolsai.jupyter-2021.10.1101450599\out\client\extension.js:66:312326)
at t.CellExecutionQueue.start (c:\Users\alex0\.vscode\extensions\ms-toolsai.jupyter-2021.10.1101450599\out\client\extension.js:66:311862)
The problem shows when I train the CNN model. The model I've built previously bumped into this problem, but it works fine when preparing other deep learning models. What I've tried:
Install anaconda, use its kernel.
re-install Jupyter notebook extension and re-open vscode.
run vscode as administrator.
All of them get no luck. The script has been tested and run sucessfully on Google Colab, and it's the alternative I am using now. Is there any way I can fix it?
Other information:
windows 11
vscode version: 1.62.3
jupyter notebook extention: v2021.10.1101450599
anaconda with its Python 3.9.6 version package
Python(self-installed): 3.9.7
I'll provide extra information if necessary. Thanks.

It's likely your kernel is crashing for some reason. Can you log an issue here?
https://github.com/microsoft/vscode-jupyter/issues.

Related

How can I visualize image using qiskit in vscode?

I'm now trying to run qiskit visualization functions(e.g. .draw() methods) in vscode.
I use latest version of Python, 3.11.1, and followed Getting Started Qiskit in here.
Also I installed qiskit extension in vscode.
However, when I run a qiskit code, the visualization functions don't work, even though code is compiled successfully.
I checked visualizing modules(mathplotlib, etc.) were installed.
I tried to re-install Python and vscode, including downgrading Python to 3.8. And it didn't work.
Additionally, qiskit-chemistry and qiskit-aqua installation warnings are pop-upped, but installation doesn't work.
I really don't know it is related on this problem, but I think maybe it's not since qiskit-aqua is deprecated.
The following screenshot is result of the qiskit test code.
result of running
draw() and plot_histogram() doesn't work as you can see.
How can I fix this problem?
These functions are meant to be used in Python Notebooks - they won't show up in normal .py files. Try using VSCode's Jupyter Notebook (.ipynb files) feature instead.

Using Matlab.engine and installing tensorflow at the same time

Currently I am working on a project with Jupyter Notebook in which I need to run a matlab script (.m) which includes a function that provides me with data which i try to solve with a tensorflow model afterwards. I can set up an environment that runs the matlab code an gives me the data and I can set up an environment that does the tensorflow thing but my problem is I can`t do it in the same environment.
Here is the setup and the problems. I am using matlab.engine which I installed like described here: https://de.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html
To run my Jupyter Notebook I first navigate to the location where my python.exe and the matlab files are lying ("C:\Users\Philipp\AppData\Local\Programs\Python\Python37-32\Scripts"). If I try to run pip install tensorflow (in Anaconda Prompt) I got a lot of different errors like the following. Conda install works but even when it is installed i can`t import it.
ImportError: No module named 'tensorflow.core' or
ERROR: Could not find a version that satisfies the requirement tensorflow or just No module named 'tensorflow'
I searched for all those problems but nothing helped me. I think this has something to do with the directory I am working in and I know it is bad but I have no idea how to change that. The error also occurs in different environments.
Have you tried running !pip install tensorflow directly in Jupyter Notebook? It's a temporary workaround, but I am having the same problems and this one helped. Remember to comment it out after installation, so you wont re-run it by accident.
I found a solution to my problem. For this I needed a Jupyter Notebook and an external .py script that I design as a Flask. I can luckily run those in different environments. I past and request the data from the server by using "get" and "post".
If someone still has another idea to do all this in one JN, I would still be happy about answers.

VSCode Jupyter Notebook syntax highlighting and autocompletion stopped working

So, I've been using VSCode for Jupyter notebooks for almost a year and a half now, and it always used to work normally, but a couple of days ago it just got broken, and I don't know why. Here's what I mean:
Jupyter Notebook on VSCode
As you can see, there's no syntax highlighting, and autocompletion doesn't work at all... but if I run the code, it does run perfectly.
It works normally in Python scripts though:
Normal Python Script
Relevant Extensions I've got:
Jupyter (+ Keymap & Notebook Renderers)
Python
Pylance
I've got a bunch of others for C++ and Java.
Also, I've noticed that both Jupyter and Python extensions give an uncaught error, here's what I mean:
Jupyter Extension Error
Python Extension Error
I have no clue what any of this means. I've tried uninstalling and re-installing the extensions, re-installing VSCode, resetting settings.json and restarting my laptop, nothing worked.
Any help will be highly appreciated. Thanks
Do you have installed the extension of Dependency Analytics? You need to disable it.
Some people have run across the same problem, you can refer to here.

jupyter notebook not showing python option under new

I am having a problem with creating a new ipython notebook.
Previously I used to do that going to new -> python
but now I am unable to see any python option.
Also, I am unable to open any ipython notebooks, I have one uploading for hours now.
I recently erased my %temp% folder to free some space in the C drive. Does that have something to do with this? How do I fix this?
I solved the problem!
For some reason, jupyter labs was not installed
So running the command
jupyter -- version
and then checking what all was installed, I found out that jupyter labs was not installed?
pip3 install jupyter labs
so I went ahead and installed it and everything works as it did before.
Still don't know the reason why this all happened in particular. If anyone could help me with that'd be awesome!
I'm not sure 100% but this is most commonly related to an ipython jupyter notebook file error. I do recommend to do a clean install of the notebook and try again. As I don't have any specifications on your system is difficult to guide you on the process. But that is the best option you have now.
Also this could have happened because of an update on python, jupyter, your system or any base component required by jupyter or python.

One last issue getting DeepChem running with TensorFlow

I'm trying to install the DeepChem multi objective deep learning code on a MacBook Pro with a Python 2.7 environment. I did a manual install of DeepChem and its required components and all seemed to go well, no errors. When I tried to run the test data I got an error "Failed to load the native TensorFlow runtime". I then installed TensorFlow again in the VirtualEnv Python environment and this again went well. The Tensorflow validation worked OK. I tried the DeepChem test examples again and got the same error "Failed to load the native TensorFlow runtime". Can anyone please suggest a solution? Should I provide a complete error path?
Your question is really general and this is not really a tensorflow problem so much as a virtualenv/dependency question.
That said here are some possible fixes:
are you sure you have activated the virtualenv (should show
environment in parentheses before the bash prompt)? If not use:
source activate ENV_NAME
if you are running from an IDE (like pycharm) are you sure you are
using the virtualenv as your interpreter? If not follow this
guide.
Again, more information about your use case would be very helpful.

Categories

Resources