Spyder WinPython Portable: pywintypes.error: (2, 'GetShortPathNameW', ...) USERPROFILE to USB

4 weeks ago 12
ARTICLE AD BOX

Context:

I am using WinPython (v3.13.8.0) from a USB drive. My goal is to make it 100% portable, ensuring no configuration folders (like .spyder-py3, .ipython, etc.) are created in the local C:\Users\Name\ directory.

​Setup:

I have modified the WinPython.ini file to redirect environment variables to a settings folder inside the USB:

[env.bat]

SPYDER_CONFDIR = %WINPYDIRBASE%\settings\.spyder-py3

JUPYTER_DATA_DIR = %WINPYDIRBASE%\settings\jupyter_data

[environment]

HOME = %WINPYDIRBASE%\settings

USERPROFILE = %HOME%

TEMP = %HOME%\temp

TMP = %HOME%\temp

The Problem:

When I launch Spyder, the IPython Console fails to start and throws the following traceback:

Traceback (most recent call last):

File "...\spyder\plugins\ipythonconsole\widgets\main_widget.py", line 1441, in _connect_new_client_to_kernel

kernel_spec.env = future.result()

File "...\spyder\plugins\ipythonconsole\utils\kernelspec.py", line 275, in env

env_vars\["tmp"\] = GetShortPathName(env_vars\["tmp"\])

pywintypes.error: (2, 'GetShortPathNameW', 'The system cannot find the file specified.')

Observations:

​The error persists even after manually creating the \settings\temp folder on the USB.

​If I revert USERPROFILE to the default Windows path, it works, but it leaves traces on the host PC (which I want to avoid).

​I have moved the WinPython folder to the root of the USB (D:\WPy64...) to avoid long path issues, but the error remains.

​Question:

How can I force Spyder/IPython to accept a portable TEMP path on a USB drive without triggering the GetShortPathNameW error? Is there a specific way WinPython handles short names on FAT32/exFAT drives that might be causing this?

Read Entire Article