spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.34k stars 1.62k forks source link

"An error occured while starting the kernel" - In Spyder, while on winpython #22562

Closed HDBlackSheep closed 3 weeks ago

HDBlackSheep commented 1 month ago

Issue Report Checklist

Problem Description

When launching Spyder, an error occurs while starting the Kernel : Kernel error

Note : I am using the portable version winpython, and I do not have admin rights on the PC I am using. I can't install or reinstall conda and am running everything with pip when I need to install a new package

What steps reproduce the problem?

  1. Launch Spyder

What is the expected output? What do you see instead?

Have Spyder launch properly.

Paste Traceback/Error Below (if applicable)


Traceback (most recent call last):
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\site‑packages\spyder\plugins\ipythonconsole\widgets\main_widget.py", line 2142, in create_kernel_manager_and_kernel_client
kernel_manager.start_kernel(stderr=stderr_handle,
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\site‑packages\jupyter_core\utils\__init__.py", line 165, in wrapped
return loop.run_until_complete(inner)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\asyncio\base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\site‑packages\jupyter_client\manager.py", line 96, in wrapper
raise e
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\site‑packages\jupyter_client\manager.py", line 87, in wrapper
out = await method(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\site‑packages\jupyter_client\manager.py", line 435, in _async_start_kernel
kernel_cmd, kw = await self._async_pre_start_kernel(**kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\site‑packages\jupyter_client\manager.py", line 400, in _async_pre_start_kernel
kw = await self.provisioner.pre_launch(**kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\site‑packages\jupyter_client\provisioning\local_provisioner.py", line 193, in pre_launch
km.write_connection_file(jupyter_session=jupyter_session)
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\site‑packages\jupyter_client\connect.py", line 500, in write_connection_file
self.connection_file, cfg = write_connection_file(
^^^^^^^^^^^^^^^^^^^^^^
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\site‑packages\jupyter_client\connect.py", line 156, in write_connection_file
with secure_write(fname) as f:
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\site‑packages\jupyter_core\paths.py", line 993, in secure_write
win32_restrict_file_to_user(fname)
File "Z:\Python portable\WPy64�\python𔂭.12.4.amd64\Lib\site‑packages\jupyter_core\paths.py", line 553, in win32_restrict_file_to_user
win32security.SetFileSecurity(fname, win32security.DACL_SECURITY_INFORMATION, sd)
pywintypes.error: (5, 'SetFileSecurity', 'Access is denied.')

Versions

Dependencies

Mandatory:

atomicwrites >=1.2.0 : 1.4.0 (OK) chardet >=2.0.0 : 5.2.0 (OK) cloudpickle >=0.5.0 : 3.0.0 (OK) cookiecutter >=1.6.0 : 2.6.0 (OK) diff_match_patch >=20181111 : 20200713 (OK) intervaltree >=3.0.2 : 3.0.2 (OK) IPython >=8.13.0,<9.0.0,!=8.17.1 : 8.25.0 (OK) jedi >=0.17.2,<0.20.0 : 0.19.1 (OK) jellyfish >=0.7 : 1.0.3 (OK) jsonschema >=3.2.0 : 4.19.2 (OK) keyring >=17.0.0 : 25.2.1 (OK) nbconvert >=4.0 : 7.16.1 (OK) numpydoc >=0.6.0 : 1.6.0 (OK) paramiko >=2.4.0 : 2.8.0 (OK) parso >=0.7.0,<0.9.0 : 0.8.4 (OK) pexpect >=4.4.0 : 4.8.0 (OK) pickleshare >=0.4 : 0.7.5 (OK) psutil >=5.3 : 5.9.8 (OK) pygments >=2.0 : 2.18.0 (OK) pylint >=3.1,<4 : 3.1.0 (OK) pylint_venv >=3.0.2 : 3.0.3 (OK) pyls_spyder >=0.4.0 : 0.4.0 (OK) pylsp >=1.11.0,<1.12.0 : 1.11.0 (OK) pylsp_black >=2.0.0,<3.0.0 : 2.0.0 (OK) qdarkstyle >=3.2.0,<3.3.0 : 3.2.3 (OK) qstylizer >=0.2.2 : 0.2.2 (OK) qtawesome >=1.3.1,<1.4.0 : 1.3.1 (OK) qtconsole >=5.5.1,<5.6.0 : 5.5.2 (OK) qtpy >=2.1.0 : 2.4.1 (OK) rtree >=0.9.7 : 1.1.0 (OK) setuptools >=49.6.0 : 69.5.1 (OK) sphinx >=0.6.6 : 7.2.6 (OK) spyder_kernels >=2.5.2,<2.6.0 : 2.5.2 (OK) textdistance >=4.2.0 : 4.5.0 (OK) three_merge >=0.1.1 : 0.1.1 (OK) watchdog >=0.10.3 : 2.2.0 (OK) zmq >=24.0.0 : 26.0.3 (OK)

Optional:

cython >=0.21 : 3.0.10 (OK) matplotlib >=3.0.0 : 3.9.0 (OK) numpy >=1.7 : 1.26.4 (OK) pandas >=1.1.1 : 2.2.2 (OK) scipy >=0.17.0 : 1.13.1 (OK)

ccordoba12 commented 1 month ago

Hey @HDBlackSheep, thanks for reporting. You said:

Note : I am using the portable version winpython, and I do not have admin rights on the PC I am using.

It seems this is the problem because you don't have the right permissions to write kernel connection files for your user alone.

However, a way to work around that would be to start Spyder in a terminal, but running there first:

set JUPYTER_ALLOW_INSECURE_WRITES=true

and then

spyder

I don't know if that's doable with WinPython. But please try to do it and let us know if it works for you.

ccordoba12 commented 3 weeks ago

Closing due to lack of response.