I can not use Python in Jupyter (in VSCode) after updating my MacOS to Ventura 13.2 (22D49). It seems to be "import pymongo" that causes the error.
I tried following actions without success:
Use ipykernel but it didn't solve the problem.
according to this video
Uninstall VSCode
Uninstall Jupyter in VSCode
I have a MacBook Pro with M1 processor.
Happy to get some suggestions!
I don't know how much of a permanent solution this is, but what worked for me was going into VS Code Extensions, search for Jupyter (which should be installed already), then at the top I chose "Switch to Pre-release version". Then you have to reload the extension and it worked for me. I hope it works for you too!
Related
Recently I reinstall my VS Code due to some errors. But I am not able to compile python files. I have installed all necessary extensions like python and code runner. But still I am getting this:
Same problem occurred to me! All I did was just disabled and then re enabled the python extension again.
OR
Please uninstall the extension, restart VS Code, and then install it again. This error is symptomatic of an extension install going badly.
I tried everything to fix this problem
1.Unistall VS Code.
2.Go to "C:/Users/{Whatever User}" and delete the .vscode Folder.
3.Go to "C:/Users/{Whatever User}/AppData/Roaming" and delete the "Code" Folder. This file stores all the VS Code Cache.
4.Restart you laptop and install VS Code again.
5.Install the python extension.
Yes they solve my other errors related to VS Code but this particular error was in my folder from which I was running my python program because when I execute some other python program saved in some other directory it worked successfully.
So I would suggest that you may try running your .py file by placing it in some new folder.
I've just had exactly the same issue. My intellisense wouldn't work too. Tried everything.. at the end I've downgraded Jupyter version. Went back to version from 6 days ago and everything is working. Python, Pylance, Intellisense extensions are the newest.
one of the solutions is you should downgrade python extension to lower extension.
please click extensions icon then choose manage button below python extension.and click install another version.
then choose older version.then select interpreter(ctrl+shift+p).
at the end restart vscode and run python file.
Help Link How to Downgrade Extension
Just Update or Uninstall and Reinstall Pylance and Python extension from Extensions...and Restart VSCode....
You may need to roll back the VS Code Python extension temporarily.
See command 'python.execInTerminal-icon' not found #3003.
Same problem. My solution is downgrade both Jupyter and Python to 2021.3.6xxx from current 2021.5
Version: 1.56.1 (user setup)
Commit: e713fe9b05fc24facbec8f34fb1017133858842b
Date: 2021-05-06T10:08:05.141Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Windows_NT x64 10.0.19041
I was too lazy to follow the recommendations for reinstalling the program on the computer, so I went into the VSC extensions, uninstalled Python, restarted VSC, installed Python, restarted VSC and everything works now. If you are as lazy as I am, then you can try this method before taking drastic measures.
Even I had the same problem but I fixed it. To fix this you have to delete VS Code completely and then reinstall it. Follow the steps:
Unistall VS Code.
Go to "C:/Users/{Whatever User}" and delete the .vscode Folder.
Go to "C:/Users/{Whatever User}/AppData/Roaming" and delete the "Code" Folder. This file stores all the VS Code Cache.
Restart you laptop and install VS Code again.
Install the python extension.
This worked for me. Hope it helps you too.
Note: If you don't find the AppData folder in you users folder, you have to enable hidden items by going to the view section in the windows explorer taskbar.
Just uninstall python extension and then restart VS Code and then install python extension again and then you will not get this error anymore.
Just update or reinstall Pylance and Python extensions and restart VS Code.
Go to the python extension, hit the arrow next to uninstall and downgrade
I Tried uninstall Reinstall VS Code Windows 10 64 bit Not Worked.
Just Uninstall all extensions in VS code.
1.open any .py file
2.Then VS CODE will show automatically to install python extension.
3.Install It Now you can see the interpreter without any issue.
NOTE:(Tried uninstalling reinstalling Extensions one by one not solved the issue)
Same here. No I've tried to relaunch VS Code, but still no python, no terminal at all (neither "Code", "Problems", or other tabs), not even was able to load the extensions menu to reinstall python. But Relaunching the PC solved the issue :)
Just uninstall VS Code, go to C:\Users\whatever user\ and delete .vscode.
Restart pc and install latest version of VS Code.
I am having trouble running my import statement in VS code Jupyter. I split them into individual cells. I find when I run
import numpy as np
the cell hangs and I get a message
Connecting to kernel: Python 3.6.9: Waiting for Jupyter Session to be idle
How do I fix this?
To solve it, I uninstalled the extension Jupyter notebook (which requires a reload), and then installed it.
This may be related to the extended version. I hope this article is helpful to you.
Alright so this one surprised me..
I was using Jupyter-like code cells "#%%" (see docs) to run jupyter notebook in VSCode. And I ran into the same issue as OP.
The error disappeared when I renamed my file, from "inspect.py" to "tmp.py".
I found my solution was to select the correct version of Python. I had 2 choices for Python 3.6.9. I chose the one called "base(Python 3.6.9)" which had a different location to "Python 3.6.9" and the base version worked. Something odd if going on here, maybe I should remove the other version?
For me, upgrading ipython to version 7.34.0 (from 7.32.0) fixed it. I'm using jedi version 0.18.1. Related
Update: this broke again for me when I upgraded my virtual environment to Python 3.8. I just upgraded my ipykernel package and now the notebook runs.
Recently I reinstall my VS Code due to some errors. But I am not able to compile python files. I have installed all necessary extensions like python and code runner. But still I am getting this:
Same problem occurred to me! All I did was just disabled and then re enabled the python extension again.
OR
Please uninstall the extension, restart VS Code, and then install it again. This error is symptomatic of an extension install going badly.
I tried everything to fix this problem
1.Unistall VS Code.
2.Go to "C:/Users/{Whatever User}" and delete the .vscode Folder.
3.Go to "C:/Users/{Whatever User}/AppData/Roaming" and delete the "Code" Folder. This file stores all the VS Code Cache.
4.Restart you laptop and install VS Code again.
5.Install the python extension.
Yes they solve my other errors related to VS Code but this particular error was in my folder from which I was running my python program because when I execute some other python program saved in some other directory it worked successfully.
So I would suggest that you may try running your .py file by placing it in some new folder.
I've just had exactly the same issue. My intellisense wouldn't work too. Tried everything.. at the end I've downgraded Jupyter version. Went back to version from 6 days ago and everything is working. Python, Pylance, Intellisense extensions are the newest.
one of the solutions is you should downgrade python extension to lower extension.
please click extensions icon then choose manage button below python extension.and click install another version.
then choose older version.then select interpreter(ctrl+shift+p).
at the end restart vscode and run python file.
Help Link How to Downgrade Extension
Just Update or Uninstall and Reinstall Pylance and Python extension from Extensions...and Restart VSCode....
You may need to roll back the VS Code Python extension temporarily.
See command 'python.execInTerminal-icon' not found #3003.
Same problem. My solution is downgrade both Jupyter and Python to 2021.3.6xxx from current 2021.5
Version: 1.56.1 (user setup)
Commit: e713fe9b05fc24facbec8f34fb1017133858842b
Date: 2021-05-06T10:08:05.141Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Windows_NT x64 10.0.19041
I was too lazy to follow the recommendations for reinstalling the program on the computer, so I went into the VSC extensions, uninstalled Python, restarted VSC, installed Python, restarted VSC and everything works now. If you are as lazy as I am, then you can try this method before taking drastic measures.
Even I had the same problem but I fixed it. To fix this you have to delete VS Code completely and then reinstall it. Follow the steps:
Unistall VS Code.
Go to "C:/Users/{Whatever User}" and delete the .vscode Folder.
Go to "C:/Users/{Whatever User}/AppData/Roaming" and delete the "Code" Folder. This file stores all the VS Code Cache.
Restart you laptop and install VS Code again.
Install the python extension.
This worked for me. Hope it helps you too.
Note: If you don't find the AppData folder in you users folder, you have to enable hidden items by going to the view section in the windows explorer taskbar.
Just uninstall python extension and then restart VS Code and then install python extension again and then you will not get this error anymore.
Just update or reinstall Pylance and Python extensions and restart VS Code.
Go to the python extension, hit the arrow next to uninstall and downgrade
I Tried uninstall Reinstall VS Code Windows 10 64 bit Not Worked.
Just Uninstall all extensions in VS code.
1.open any .py file
2.Then VS CODE will show automatically to install python extension.
3.Install It Now you can see the interpreter without any issue.
NOTE:(Tried uninstalling reinstalling Extensions one by one not solved the issue)
Same here. No I've tried to relaunch VS Code, but still no python, no terminal at all (neither "Code", "Problems", or other tabs), not even was able to load the extensions menu to reinstall python. But Relaunching the PC solved the issue :)
Just uninstall VS Code, go to C:\Users\whatever user\ and delete .vscode.
Restart pc and install latest version of VS Code.
I'm trying Anaconda/Spyder after using the standard python installation/IDLE for several years. The console (and variable explorer) becomes progressively slower during each work session, with every script and interactive command that I run. Eventually it takes minutes to get a response to simple commands like print, and then it stops responding completely and I shut it down. It's pretty disruptive to my work.
Mac OSX 10.13.6
conda version : 4.5.11
conda-build version : 3.15.1
python version : 3.7.0.final.0
qt 5.9.6
spyder 3.3.1
ipython 7.1.1
I do use matplotlib frequently. Whenever possible I use plt.ioff() at the beginning of a script and/or plt.close('all') at the end. Turning off matplotlib support completely in preferences doesn't help and it's not a permanent fix anyway. Python is not using anywhere near all my CPU or RAM.
As far as I've found out, the problem seems to be with the latest major release of the ipython kernel. Pinning the version of ipykernel to 4.10.0 solved it for me. To do so, add a line containing ipykernel 4.* to the file ~/anaconda3/conda-meta/pinned. Create the file if it does not exist yet. Then conda update ipykernel which will actually downgrade to 4.10.0. Worked for me!
you don't need to downgrade the entire spyder.
For me it worked with downgrading these two:
conda install ipython=6.4.0
conda install ipykernel=4.10.0
So this is not a totally satisfying solution but it seems to be a reasonable temporary fix. If you downgrade your spyder version to 3.1.X you will be able to use the python console rather than the Ipython console, and this seems to work for me. To do this just run:
conda install spyder=3.1
in the terminal while your environment of choice is active. This is not ideal, because the developers removed the python console for a specific reason as mentioned in this question, How to add python console in spyder.
Additionally downgrading this much may have unforeseen effects on other packages your code uses and may cause other issues but so far this is the only solution I was able to come up with.
#Sjoerd Thanks for your answer, this is what worked for me. To be still clearer, here's what I did in terminal on Anaconda 3 on High Sierra:
echo "ipykernel 4.10.0" >> ~/anaconda3/conda-meta/pinned
conda update anaconda
When I tried to update only ipykernel, I would have dependencies errors. By updating anaconda, everything is now up to date but ipykernel which is effectively at version 4.10.0. I didn't experience any hang since then.
#JJR4's answer didn't work for me (seems to work for others). Another workaround is to type %connect_info magic command into the IPython Spyder console which will display the JSON info to connect another console to the kernel.
The output of the magic command explains how to connect, but basically there are three options.
Paste the above JSON into a file, and connect with:
$> jupyter <app> --existing <file>
or, if you are local, you can connect with just:
$> jupyter <app> --existing <kernel>.json
or even just:
$> jupyter <app> --existing
if this is the most recent Jupyter kernel you have started.
I typically use qtconsole as the app. Once you enter your chosen connection method into the command line, a new console will open that is connected to the same kernel as the console in Spyder. For some reason, the new console does not lag even if the Spyder console does.
Enter everything in the new console, even runfile()
Hope this helps!
UPDATE:
Downgrading to ipykernel version 4.10 seems to solve the issue for me. Thanks to Carlos Cordoba - see GitHub conversation in link below.
I want to use tensorflow insinde a Jupyter notebook. However, running
import tensorflow as tf
in a Jupyter notebook immediately triggers a pop-up:
The kernel appears to have died. It will restart automatically.
This issue only began after updating to tensorflow 1.7. I had not used tensorflow for a few weeks so it might also be due to an update to anaconda 5.1 with Python 3.6.
I use a Mid-2010 MacBookPro with "High Sierra 10.13.4". Removing and reinstalling anaconda 5.1 with Python 3.6, followed by installation of tensorflow (and not a single other library) via
pip3 install --upgrade tensorflow
did not resolve the issue. I do not use an isolated environment. The "anaconda3" folder is not in my home folder but directly in "Macintosh HD".
Before reinstalling anaconda, I removed it via these instructions
https://docs.anaconda.com/anaconda/install/uninstall. I also did not try to run tensorflow outside Jupyter, simply because I do not know how. But even if I did, I would still like to use Jupyter.
I'm also running a Mid-2010 MacbookPro and have been facing the same issue. It seems the only solution is to downgrade to Tensorflow 1.5. You can do so by running the following:
pip3 uninstall tensorflow
pip3 install tensorflow==1.5
Credit given to the solution to this post.
I was facing the same issue with Tensorflow 2 '2.0.0-beta1'. I found out that when you have multiple notebooks with Tensorflow running, this problem occurs. Also, simply closing the unused notebook windows wont work, they're still running in the background, you'll have to 'Shutdown' the notebooks
Here are the steps to shutdown a notebooks:
> Go to Home (of Jupyter notebook)
> Select 'Running' tab
> Select the unused notebooks
> Click 'Shutdown' button
You will notice in the Jupyter Home that the active notebook icon is green while inactive ones are gray
I have also faced a similar issue.
I was using python 3.7 and Tensorflow version 1.5
For we moving to Python 3.5 solve the issue.