Kernel Error in anaconda Jupyter Notebook: ImportError - python

I caught up with the following error
Traceback (most recent call last):
File "C:\Users\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\tornado\web.py", line 1704, in _execute
result = await result
File "C:\Users\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
model = yield maybe_future(
File "C:\Users\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "C:\Users\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\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\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "C:\Users\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 110, in start_kernel_for_session
kernel_id = yield maybe_future(
File "C:\Users\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "C:\ProgramData\Anaconda3\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\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\jupyter_client\multikernelmanager.py", line 186, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\jupyter_client\manager.py", line 337, in start_kernel
kernel_cmd, kw = self.pre_start_kernel(**kw)
File "C:\Users\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\jupyter_client\manager.py", line 286, in pre_start_kernel
self.write_connection_file()
File "C:\Users\Abhilash H.P\AppData\Roaming\Python\Python38\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\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\jupyter_client\connect.py", line 136, in write_connection_file
with secure_write(fname) as f:
File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\Users\Abhilash H.P\AppData\Roaming\Python\Python38\site-packages\jupyter_core\paths.py", line 461, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\Abhilash H.P\AppData\Roaming\Python\Python38\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.
How to troubleshoot this error?
I tried almost all possible solutions available on Stack Overflow, Youtube, and even i removed anaconda and Python and its dependencies completely and reinstalled the same. but still its not working.

The error is related to "pywin", try this if you already have that package :
pip install --upgrade pywin32==225
Or this
pip install pywin32==225

Problem Resolved by resetting the environment variables...
If anyone caught up with same error just check the path of anaconda installation directory and check environment variables whether they are also matching the same...
Step 1: Search for Environment Variable in the windows search bar
Step 2: Under System properties dialog box select Environment Variables
Step 3: Check the Anaconda Installation Directory Path in your system (User/System)
Step 4: If it is in User, Select Path under User Variables otherwise select Path under System Variables and Click on Edit
Step 5: Select New from Edit Environment Variables dialog box
Step 6: Paste the Anaconda Installation Directory Path.
Step 7: Done
Step 8: If it doesn't work better you delete all the Path Variables related to Python and Anaconda and Uninstall anaconda and its all dependencies, delete all the files related to Anaconda and Python...and reinstall anaconda...It works...
Thank you...

I followed these steps:
To craete new virtual environment in Anaconda type the following Command
Step 1: conda create -n myenv python=Version (python=3.8)
First activate the created environment
Step 2: conda activate myenv
First, activate your virtual environment and run this code.
Step 3:pip install --user ipykernel
We need to manually add the kernel if we want to have the virtual environment in the Jupyter Notebook. That is why we need to add it by running this code.
Step 4: python -m ipykernel install --user --name=myenv
With this, we have set up our virtual environment kernel and ready to be used in the Jupyter Notebook.
In my case error is because of, DLL load failed while importing win32api, this Import Error.
It is resolved by the command by #Alama1:
pip install pywin32==225

Related

python poetry installation failed on Windows 10 - no pyvenv.cfg file

I installed Python 3.9 using winget.
PS C:\Users\andre> winget list PythonSoftware
Name ID Version
-----------------------------------------------------------------------
Python 3.9 PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0 3.9.2544.0
I am trying to install poetry. Therefore, I downloaded the new installation script from https://install.python-poetry.org/ and run it within a Windows terminal. Here's the output:
PS C:\Users\andre\Downloads> python .\install-poetry.py
Retrieving Poetry metadata
# Welcome to Poetry!
This will download and install the latest version of Poetry,
a dependency and package manager for Python.
It will add the `poetry` command to Poetry's bin directory, located at:
C:\Users\andre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Scripts
You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.
Installing Poetry (1.1.12)
Installing Poetry (1.1.12): Creating environment
Actual environment location may have moved due to redirects, links or junctions.
Requested location: "C:\Users\andre\AppData\Roaming\pypoetry\venv\Scripts\python.exe"
Actual location: "C:\Users\andre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Roaming\pypoetry\venv\Scripts\python.exe"
Actual environment location may have moved due to redirects, links or junctions.
Requested location: "C:\Users\andre\AppData\Roaming\pypoetry\venv\Scripts\python.exe"
Actual location: "C:\Users\andre\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Roaming\pypoetry\venv\Scripts\python.exe"
Installing Poetry (1.1.12): An error occurred. Removing partial environment.
Poetry installation failed.
See C:\Users\andre\Downloads\poetry-installer-error-bzs5mfpr.log for error logs.
And finally the output of the respective log file:
No pyvenv.cfg file
Traceback:
File "C:\Users\andre\Downloads\install-poetry.py", line 872, in main
return installer.run()
File "C:\Users\andre\Downloads\install-poetry.py", line 503, in run
self.install(version)
File "C:\Users\andre\Downloads\install-poetry.py", line 524, in install
with self.make_env(version) as env:
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\contextlib.py", line 119, in __enter__
return next(self.gen)
File "C:\Users\andre\Downloads\install-poetry.py", line 596, in make_env
raise e
File "C:\Users\andre\Downloads\install-poetry.py", line 582, in make_env
yield VirtualEnvironment.make(env_path)
File "C:\Users\andre\Downloads\install-poetry.py", line 317, in make
env.pip("install", "--disable-pip-version-check", "--upgrade", "pip")
File "C:\Users\andre\Downloads\install-poetry.py", line 340, in pip
return self.python("-m", "pip", "--isolated", *args, **kwargs)
File "C:\Users\andre\Downloads\install-poetry.py", line 337, in python
return self.run(self._python, *args, **kwargs)
File "C:\Users\andre\Downloads\install-poetry.py", line 330, in run
raise PoetryInstallationError(
Apparently, there's some issue with the place where Python has been installed, isn't it? How can I solve that issue?
This indeed is path issue with multiple versions of Python Installation , especially the version from Microsoft is not setting the path properly us the installer from https://www.python.org/downloads/ it fixes the error

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"
}

Is it possible to run jupyter from nside a virtual env

For now I was only using python 2.7 (installed for all users, added to path, windows 10 machine) but I want to switch to 3.8, to be able to use both of them I first installed virtualenv in my system python 2.7.
Then installed python 3.8.1 for all user without adding it to path.
Created my virtualenv like that : virtualenv c:\virtualEnvs\p38x64_jupytertest -p C:\Python38-32\python.exe
then activated it : C:\virtualEnvs\p38x64_jupytertest\Scripts\activate.bat
checked if python 3.8.1 was selected with : python --version (it was)
then installed jupyter inside my virtualenv : pip install jupyter
Then when I ran jupyter notebook I got
Traceback (most recent call last):
File "C:\Python38-32\Lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Python38-32\Lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\virtualEnvs\p38x64_jupytertest3\Scripts\jupyter-notebook.EXE\__main__.py", line 7, in <module>
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\jupyter_core\application.py", line 268, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\traitlets\config\application.py", line 663, in launch_instance
app.initialize(argv)
File "<c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\decorator.py:decorator-gen-7>", line 2, in initialize
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\notebook\notebookapp.py", line 1720, in initialize
self.init_webapp()
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\notebook\notebookapp.py", line 1482, in init_webapp
self.http_server.listen(port, self.ip)
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\tcpserver.py", line 152, in listen
self.add_sockets(sockets)
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
self._handlers[sock.fileno()] = add_accept_handler(
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
io_loop.add_handler(sock, accept_handler, IOLoop.READ)
File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\platform\asyncio.py", line 99, in add_handler
self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
File "C:\Python38-32\Lib\asyncio\events.py", line 501, in add_reader
raise NotImplementedError
NotImplementedError
After some googling I find a lot of tutorial that explain how to install jupyter in you system python then add virtualenvs to it, but not how to install it INSIDE a virtual env.
The reason I did that is because I want my python 3 project to be isolated since I have a lot of python 2.7 projects (up until now I was not using virtualenv and every package is installed in my system python 2.)
Any idea of why I have this exception?
Thanks.
PS : yes it says p38x64_jupytertest3 in the stacktrace because the venv is not p38x64_jupytertest but p38x64_jupytertest3 in fact
know issue : https://github.com/jupyter/notebook/issues/4613
Reverting to python 3.7 for the moment

Kernel Error in Jupyter Notebook, don't know what to do, am new to this

Traceback (most recent call last):
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\Kath.000\Anaconda3\lib\contextlib.py", line 112, in enter
return next(self.gen)
File "C:\Users\Kath.000\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 102, in secure_write
with os.fdopen(os.open(fname, open_flag, 0o600), mode) as f:
PermissionError: [Errno 13] Permission denied: 'C:\Users\Kath.000\AppData\Roaming\jupyter\runtime\kernel-451bd345-5996-4658-8c31-dbdb280931d9.json'
I guess from your log that you also installed Anaconda3. I installed Anaconda 2019.10 for Windows yesterday and I'm having the same error.
Simple answer
Downgrading anaconda to 2019.07 which is the previous version.
How to downgrade anacondafrom Anaconda Emvironments GUI.
Open Anaconda Navigator.
Change to Environments tab.
Right click 'anaconda' in list.
Slide mouse cursor to 'Mark for specific version installation'.
Select '2019.07'.
Apply the downgrade.
2019-10-25 Add: After I tried upgrading anaconda to '2019.10' once again. jupyter_client became ver.5.3.4, not ver.5.3.3.This change solved the problem on my environment.
2019-11-12 Add: The same issue occurred on another PC. I noticed that "Mark specific version installation" is grayed out after a new installation. "Mark specific version installation" is enabled after running "Update Index ...". Although I downgraded anaconda using the same procedure as the last time, you may be able to solve this issue simply by upgrading anaconda.
jupyter_client became ver.5.3.4
Long answer
From here,
Kernel error in jupyter notebook #4909
. The following components seem to be the cause.
jupyter_client 5.3.3
pywin32 223
The solution is mentioned as below.
Downgrading jupyter_client to version 5.3.1.
conda install jupyter_client=5.3.1
Or upgrading pywin32 to version 224.
conda install pywin32=224
I operated them from the GUI of Anaconda Navigator. However both of them are not worked on my anaconda environment. I tried 'conda install pywin32=224' from Terminal but it stopped in the middle of processing. Probably dependencies between packages prevent these operations. I didn't want to spend time to installing software, so I choose to downgrade anaconda to the previous version.
Consideration in taking this solution.
This solution prevents you from installing other latest packages. For example, numpy=1.16.4, scikit-learn=0.21.2 scipy=1.2.1 become unavailable.
I hope that this information is helpful to you.

Why do I have a Kernel Error in Jupyter Notebook?

I am a newbie to python. I am getting the below error in Kernel while opening jupyter notebook. Any ideas how I can resolve it? Installation of jupyter has been done via Anaconda3 - tried reinstalling and setting environment variables, but no luck so far. Any help would be greatly appreciated.
Traceback (most recent call last):
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\drag88\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 100, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 53, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed: The specified procedure could not be found.
Step 2 command: conda activate (location of your env folder)
Step 3 command: python -m ipykernel install --user
Works for Windows.
It looks like you had installed jupyter when there was an issue with its dependencies on Windows. See https://github.com/jupyterlab/jupyterlab/issues/7259 . I ran into the same error.
It should be fixed on conda now, so if you uninstall and reinstall jupyterlab from conda, it should not throw that error anymore.
I battled to get Jupyter working on my Windows 10 office computer for a number of hours. This was after installing Anaconda3. I had versions of Python 2 and 3 installed before. I was getting 'Kernel error' and also had various errors about 'win32api' and 'tornado'
I did many things but in the end main ones that, I think, helped are listed below -
On install, Anaconda3 created a data folder here -
C:\ProgramData\Anaconda3
I gave my user account access to write to this folder, I am not sure if it made a difference.
Elevated to admin, I copied two dll files as below -
pythoncom39.dll
pywintypes39.dll
From -
C:\ProgramData\Anaconda3\Lib\site-packages\pywin32_system32
To -
C:\windows\system32
At the 'Anaconda Prompt', a Windows cmd screen (which was added to my start menu) after the install, I did this -
(base) C:\>conda env create test-env
It created 'test-env' folder at C:\Users\{windows user name}\.conda\envs\test-env
(base) C:\>conda activate "C:\Users\{windows user name}\.conda\envs\test-env"
(test-env) C:\>
Once in this newly created environment, I tried various other things such as these -
conda install jupyter
conda install pywin32
python -m ipykernal install --user
Launching jupyter after loading and setting to this environment now works by using this command -
(test-env) C:\>jupyter notebook
When browser opens, select New>python 3 (ipykernel) from right hand menu to create new notebook.
If you have Python installed on your pc run from cmd or powershell:
pip install jupyterlab
Then you can start it with:
jupyter lab
The installation might have missed some steps which are fixed by post_install.
Go to yout venv's Script directory and run the command
python .\pywin32_postinstall.py -install
Make sure you are running the shell with Admin rights.
This error is sometimes as a result of the deleted environment that was created before. For Windows users, run the following code in cmd
python -m ipykernel install –user
Simply uninstall and install jupyter by first:
#Activate your environment in anaconda prompt (conda activate"path") and then type:-
conda uninstall jupyter
conda install jupyter

Categories

Resources