jupyter notebook does not connect to kernel - python

I want to use jupyter notebook but it does not want to connect to the kernel.
I tried updating anaconda and started jupyter from the anaconda prompt.
I got this error:
Traceback (most recent call last):
File "C:\Users\felix\Anaconda3\lib\site-packages\tornado\web.py", line 1592, in _execute
result = yield result
File "C:\Users\felix\Anaconda3\lib\site-packages\tornado\gen.py", line 1133, in run
value = future.result()
File "C:\Users\felix\Anaconda3\lib\site-packages\tornado\gen.py", line 1147, in run
yielded = self.gen.send(value)
File "C:\Users\felix\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\handlers.py", line 67, in post
model = yield gen.maybe_future(sm.get_session(path=path))
File "C:\Users\felix\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 170, in get_session
return self.row_to_model(row)
File "C:\Users\felix\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 209, in row_to_model
raise KeyError
KeyError

downgrade tornado to 4.5.3 seemed to solve it. I can use jupyter via the conda prompt. But it still doesn't work together with VS Code.

Related

Can't connect to Python through Jupyter Notebook in a virtual environment

I've created a virtual environment in my working folder and a jupyter notebook but it seems like my jupyter notebook is not connected to Python.
I've created a virtual environment inside this directory(C:\Users\MyName\Documents\DataScience\Code) by running the following commands:
pip install virtualenv
virtualenv .venv
.venv\Scripts\activate
Then, I've installed these two following packages.
pip install jupyter
pip install jupyterlab
After installing jupyter, I opened the jupyter notebook by typing in "jupyter notebook" in the command prompt and it worked. When I type in "Jupyter Notebook", the browser pops up. But if I try to create a new notebook in the jupyter browser by clicking the "New" dropdown menu and selecting "Python 3" it gives me an error. It let me open a new notebook but it throws a Kernel error. It still says Python 3 (ipykernel) on the top right corner but with a black dot that looks like a bomb icon.
Normally, when I create a new jupyter notebook, it just says Python 3 without ipykernel. I've tried "pip(or conda) install pywin32" but it didn't work. How do I solve this error and connect my notebook to Python? I have Python3.8 on my computer and would like to connect jupyter notebook to regular Python 3 without ipykernel.
FYI, this is an error message I see when I click on the kernel error.
Traceback (most recent call last):
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\tornado\web.py", line 1704, in _execute
result = await result
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
model = yield maybe_future(
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 98, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 110, in start_kernel_for_session
kernel_id = yield maybe_future(
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 176, in start_kernel
kernel_id = await maybe_future(self.pinned_superclass.start_kernel(self, **kwargs))
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\jupyter_client\multikernelmanager.py", line 186, in start_kernel
km.start_kernel(**kwargs)
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\jupyter_client\manager.py", line 337, in start_kernel
kernel_cmd, kw = self.pre_start_kernel(**kw)
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\jupyter_client\manager.py", line 286, in pre_start_kernel
self.write_connection_file()
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\jupyter_client\connect.py", line 466, in write_connection_file
self.connection_file, cfg = write_connection_file(self.connection_file,
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\jupyter_client\connect.py", line 136, in write_connection_file
with secure_write(fname) as f:
File "c:\users\MyName\anaconda3\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\jupyter_core\paths.py", line 461, in secure_write
win32_restrict_file_to_user(fname)
File "c:\users\MyName\Documents\DataScience\Code\.venv\lib\site-packages\jupyter_core\paths.py", line 387, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed while importing win32api: The specified procedure could not be found.
Thank you.
Jupyter Notebook makes sure that the IPython kernel is available, but you have to manually add a kernel with a different version of Python or a virtual environment.
pip install --user ipykernel
Next you can add your virtual environment to Jupyter by typing:
python -m ipykernel install --user --name=myenv
This should print the following:
Installed kernelspec myenv in /home/user/.local/share/jupyter/kernels/myenv
In this folder you will find a kernel.json file which should look the following way if you did everything correctly:
{
"argv": [
"/home/user/anaconda3/envs/myenv/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "myenv",
"language": "python"
}

RunTimeError: pdf Latex not install

$ schtex drawing.sch drawing.png
When I try to run the above code it says that I don't have pidflatex installed even though I have pip installed latex, tex, and pdflatex.
I have also run the following lines when testing another piece of code and it failed to obtain anything:
from sympy.utilities.misc import find_executable
find_executable('latex')
It also gave me an error
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/bin/schtex", line 8, in <module>
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/lcapy/scripts/schtex.py", line 231, in main
cct.draw(label_nodes=args.label_nodes,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/lcapy/netlistmixin.py", line 1624, in draw
return cct.sch.draw(filename=filename, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/lcapy/schematic.py", line 792, in draw
self.tikz_draw(filename=filename, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/lcapy/schematic.py", line 597, in tikz_draw
self.circuitikz_date, self.circuitikz_version = latexrunner.circuitikz_version()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/lcapy/system.py", line 230, in circuitikz_version
self.run(tex_filename)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/lcapy/system.py", line 183, in run
checkexe('pdflatex')
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/lcapy/system.py", line 68, in checkexe
raise RuntimeError('%s is not installed' % program)
RuntimeError: pdflatex is not installed
From my experience, running these packages require to actually have a LaTeX distribution installed on your computer (which contains pdflatex).
I would recommend you using teXlive, which is one of the most common : https://www.tug.org/texlive/
You could also use MikTeX which is also a very common distribution : https://miktex.org/

spyder launch error: self.curr_filenames.pop(index) pop index out of range

my spyder won't launch and shows the following err: (
I just uninstalled old anaconda from windows remove programs, and reinstalled Anaconda3-2020.07-Windows-x86_64.exe.)
(base) C:\Users\XYZ>spyder
Traceback (most recent call last):
File "C:\Users\XYZ\Anaconda3\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\XYZ\Anaconda3\lib\site-packages\spyder\app\start.py", line 219, in main
mainwindow.main()
File "C:\Users\XYZ\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3763, in main
mainwindow = run_spyder(app, options, args)
File "C:\Users\XYZ\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3638, in run_spyder
main.setup()
File "C:\Users\XYZ\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 984, in setup
plugin = module.PLUGIN_CLASS(self)
File "C:\Users\XYZ\Anaconda3\lib\site-packages\spyder\plugins\pylint\plugin.py", line 56, in __init__
self.pylint = PylintWidget(self, max_entries=max_entries,
File "C:\Users\XYZ\Anaconda3\lib\site-packages\spyder\plugins\pylint\widgets\pylintgui.py", line 252, in __init__
self.set_filename(f)
File "C:\Users\XYZ\Anaconda3\lib\site-packages\spyder\plugins\pylint\widgets\pylintgui.py", line 279, in set_filename
self.curr_filenames.pop(index)
IndexError: pop index out of range
[13520:380:0727/173051.399:ERROR:broker_win.cc(59)] Error reading broker pipe: The pipe has been ended. (0x6D)
[19460:22120:0727/173051.400:ERROR:broker_win.cc(59)] Error reading broker pipe: The pipe has been ended. (0x6D)
I've been stuck on this issue for the past 4 hours... Trying many uninstalls and installs, etc.
My fix was:
When in the Anaconda Prompt:
spyder --reset

Not able to launch Spyder version 4.1.1

I recently created a new environment with Anaconda Navigator and installed in it the Spyder IDE version 4.1.1. The problem is, whenever I try to launch it (via Anaconda Navigator), it raises me the following exception, and doesn´t launch at all:
Traceback (most recent call last):
File "C:\Users\marco\anaconda3\envs\Webscraping_env\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\Users\marco\anaconda3\envs\Webscraping_env\lib\site-packages\spyder\app\start.py", line 205, in main
mainwindow.main()
File "C:\Users\marco\anaconda3\envs\Webscraping_env\lib\site-packages\spyder\app\mainwindow.py", line 3700, in main
mainwindow = run_spyder(app, options, args)
File "C:\Users\marco\anaconda3\envs\Webscraping_env\lib\site-packages\spyder\app\mainwindow.py", line 3556, in run_spyder
main.setup()
File "C:\Users\marco\anaconda3\envs\Webscraping_env\lib\site-packages\spyder\app\mainwindow.py", line 1217, in setup
self.apply_shortcuts()
File "C:\Users\marco\anaconda3\envs\Webscraping_env\lib\site-packages\spyder\app\mainwindow.py", line 3207, in apply_shortcuts
self.help.show_intro_message()
File "C:\Users\marco\anaconda3\envs\Webscraping_env\lib\site-packages\spyder\plugins\help\plugin.py", line 456, in show_intro_message
shortcut_editor, "\n\n", prefs)
TypeError: not enough arguments for format string
But when I go to the root environment and try to launch from there Spyder version 4.0.1, it launchs with no issues.

Canopy is having difficulties updating packages, "AbortedOperationDetected"

I run Canopy version Version: 2.1.3.3542 (64 bit) on Windows 10.
Canopy cant manage to update any package, all results in the same
log output for a numpy update (for example):
Warming up...
Traceback (most recent call last):
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\package_action_worker.py", line 54, in run
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\package_action.py", line 196, in execute
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\packman.py", line 626, in <lambda>
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\packman.py", line 1051, in _install
File "build\bdist.win-amd64\egg\canopy_platform\cpython_packages_manager.py", line 152, in install_packages_prompt
File "build\bdist.win-amd64\egg\canopy_platform\cpython_packages_manager.py", line 137, in _install_packages_prompt
PackagesInstallationError: installation of packages ['numpy 1.11.3-3'] failed. Details below:
Traceback (most recent call last):
File "build\bdist.win-amd64\egg\canopy_platform\edm_api.py", line 64, in wrapper
File "build\bdist.win-amd64\egg\canopy_platform\edm_api.py", line 384, in install_command
File "build\bdist.win-amd64\egg\canopy_platform\edm_api.py", line 414, in _install_packages_command
File "build\bdist.win-amd64\egg\edm\core\packages_manager.py", line 124, in decorator
File "build\bdist.win-amd64\egg\edm\core\packages_manager.py", line 219, in install_command
File "build\bdist.win-amd64\egg\edm\core\packages_manager.py", line 223, in _install_command
File "build\bdist.win-amd64\egg\edm\core\packages_manager.py", line 549, in _compute_fix_aborted_actions
AbortedOperationDetected: Aborted operation detected in environment 'User'
There is absolutly 0 results on google for this error code, so stackexchange is my last resort
It looks like a previous update was force-aborted, possibly leaving the environment corrupted. Assuming that you are using the standard installer, then it should suffice to
reboot your computer
temporarily disable your anti-virus software if possible (or at least disable its more intrusive / slow functionality, such as online checking each of the tens of thousands of package files that Canopy provides),
from the Canopy Tools menu, select Troubleshoot => Reset Python environment

Categories

Resources