Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to start kernel in pip installations inside conda environments on Windows due a missing DLL #304

Open
dalthviz opened this issue Jul 23, 2021 · 3 comments

Comments

@dalthviz
Copy link
Member

Running python -m spyder_kernels.console can cause the following traceback on a conda env where everything is installed with pip:

Traceback (most recent call last):
  File "C:\Users\Daniel\Anaconda3\envs\spip5.0.5\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Daniel\Anaconda3\envs\spip5.0.5\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Daniel\Anaconda3\envs\spip5.0.5\lib\site-packages\spyder_kernels\console\__main__.py", line 23, in <module>
    start.main()
  File "C:\Users\Daniel\Anaconda3\envs\spip5.0.5\lib\site-packages\spyder_kernels\console\start.py", line 288, in main
    kernel.initialize()
  File "C:\Users\Daniel\Anaconda3\envs\spip5.0.5\lib\site-packages\traitlets\config\application.py", line 87, in inner
    return method(app, *args, **kwargs)
  File "C:\Users\Daniel\Anaconda3\envs\spip5.0.5\lib\site-packages\ipykernel\kernelapp.py", line 626, in initialize
    self.write_connection_file()
  File "C:\Users\Daniel\Anaconda3\envs\spip5.0.5\lib\site-packages\ipykernel\kernelapp.py", line 235, in write_connection_file
    write_connection_file(cf, ip=self.ip, key=self.session.key, transport=self.transport,
  File "C:\Users\Daniel\Anaconda3\envs\spip5.0.5\lib\site-packages\jupyter_client\connect.py", line 136, in write_connection_file
    with secure_write(fname) as f:
  File "C:\Users\Daniel\Anaconda3\envs\spip5.0.5\lib\contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "C:\Users\Daniel\Anaconda3\envs\spip5.0.5\lib\site-packages\jupyter_core\paths.py", line 461, in secure_write
    win32_restrict_file_to_user(fname)
  File "C:\Users\Daniel\Anaconda3\envs\spip5.0.5\lib\site-packages\jupyter_core\paths.py", line 387, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed while importing win32api: No se puede encontrar el módulo especificado

@dalthviz
Copy link
Member Author

Notes:

  • Related to pywin32 and some DLLs that are copied at postinstall of the package
  • Running conda install pywin32 setups the missing DLLs (in my case)

@Lynn-Kang
Copy link

Lynn-Kang commented Aug 5, 2021

Me, neither.

Actually, I'd removed the well-installed first Spyder.. but after that installation, I failed to start kernel both Spyder and Jupyter notebook.

Traceback (most recent call last):
File "C:\Users\USER\AppData\Roaming\Python\Python38\site-packages\tornado\web.py", line 1704, in _execute
result = await result
File "C:\Users\USER\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\USER\anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
model = yield maybe_future(
File "C:\Users\USER\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "C:\Users\USER\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\USER\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\USER\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "C:\Users\USER\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\USER\anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 110, in start_kernel_for_session
kernel_id = yield maybe_future(
File "C:\Users\USER\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "C:\Users\USER\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\USER\AppData\Roaming\Python\Python38\site-packages\jupyter_client\multikernelmanager.py", line 186, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\USER\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\USER\AppData\Roaming\Python\Python38\site-packages\jupyter_client\manager.py", line 286, in pre_start_kernel
self.write_connection_file()
File "C:\Users\USER\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\USER\AppData\Roaming\Python\Python38\site-packages\jupyter_client\connect.py", line 136, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\USER\anaconda3\lib\contextlib.py", line 113, in enter
return next(self.gen)
File "C:\Users\USER\AppData\Roaming\Python\Python38\site-packages\jupyter_core\paths.py", line 461, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\USER\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: %1은(는) 올바른 Win32 응용 프로그램이 아닙니다.

@dalthviz
Copy link
Member Author

dalthviz commented Aug 6, 2021

Hi @Lynn-Kang are you using only conda? Seems to me that you are using also pip (the installer should not leave behind files in the path were the traceback is pointing things). Maybe sticking with only one python distribution could be better. Either keep the python installation managed through pip (the one located at ...AppData\Roaming...) or use just conda. If you want to go with conda then I think you will need to remove that Python folder at ...AppData\Roaming....

But just in case, is that correct @ccordoba12 right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants