pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Error parsing pth file

Open hunterhogan opened this issue 9 months ago • 7 comments

Type: Bug

2025-05-27 22:12:49.423 [info] (Client) Pylance async client (2025.5.100) started with python extension (2025.7.2025052701) 2025-05-27 22:12:52.759 [info] [Info - 10:12:52 PM] (2536) Server root directory: file:///c%3A/Users/hunte/.vscode-insiders/extensions/ms-python.vscode-pylance-2025.5.100/dist 2025-05-27 22:12:52.759 [info] [Info - 10:12:52 PM] (2536) Pylance language server 2025.5.100 (pyright version 1.1.400, commit b962ffc2) starting 2025-05-27 22:12:52.805 [info] [Info - 10:12:52 PM] (2536) Starting service instance "astToolFactory" for workspace "c:\apps\astToolFactory" 2025-05-27 22:12:52.907 [info] [Info - 10:12:52 PM] (2536) Loading pyproject.toml file at c:\apps\astToolFactory\pyproject.toml 2025-05-27 22:12:52.909 [info] [Info - 10:12:52 PM] (2536) Setting environmentName for service "astToolFactory": "3.13.3 (.venv venv)" 2025-05-27 22:12:52.911 [info] [Info - 10:12:52 PM] (2536) Setting pythonPath for service "astToolFactory": "C:\apps\astToolFactory.venv\Scripts\python.exe" 2025-05-27 22:12:52.912 [info] [Info - 10:12:52 PM] (2536) No include entries specified; assuming c:\apps\astToolFactory 2025-05-27 22:12:53.016 [info] [Info - 10:12:53 PM] (2536) Assuming Python version 3.13.3.final.0 2025-05-27 22:12:53.194 [info] [Info - 10:12:53 PM] (2536) Found 13 source files 2025-05-27 22:12:53.233 [info] [Info - 10:12:53 PM] (2536) Loading pyproject.toml file at c:\apps\astToolFactory\pyproject.toml 2025-05-27 22:12:53.234 [info] [Info - 10:12:53 PM] (2536) Setting environmentName for service "astToolFactory": "3.13.3 (.venv venv)" 2025-05-27 22:12:53.235 [info] [Info - 10:12:53 PM] (2536) Setting pythonPath for service "astToolFactory": "C:\apps\astToolFactory.venv\Scripts\python.exe" 2025-05-27 22:12:53.235 [info] [Info - 10:12:53 PM] (2536) No include entries specified; assuming c:\apps\astToolFactory 2025-05-27 22:12:53.352 [info] [Info - 10:12:53 PM] (2536) Assuming Python version 3.13.3.final.0 2025-05-27 22:12:53.509 [info] [Info - 10:12:53 PM] (2536) Found 13 source files 2025-05-27 22:12:53.806 [info] [Info - 10:12:53 PM] (2536) BG: Priority queue background worker(2) root directory: file:///c%3A/Users/hunte/.vscode-insiders/extensions/ms-python.vscode-pylance-2025.5.100/dist 2025-05-27 22:12:53.807 [info] [Info - 10:12:53 PM] (2536) BG: Priority queue background worker(2) started 2025-05-27 22:12:55.714 [info] Error parsing pth file: Error processing line 7 of /c:\apps\astToolFactory.venv\Lib\site-packages/pywin32.pth:

2025-05-27 22:12:55.714 [info] Error parsing pth file:

Error parsing pth file: Traceback (most recent call last):

Error parsing pth file: File "", line 206, in addpackage

Error parsing pth file: File "", line 1, in

2025-05-27 22:12:55.714 [info] Error parsing pth file: File "/$c$/apps\astToolFactory.venv\Lib\site-packages\win32\lib/pywin32_bootstrap.py", line 20, in

Error parsing pth file: os.add_dll_directory(path)

2025-05-27 22:12:55.715 [info] Error parsing pth file: ^^^^^^^^^^^^^^^^^^^^

Error parsing pth file: AttributeError: module 'os' has no attribute 'add_dll_directory'

Error parsing pth file: Remainder of file ignored

2025-05-27 22:12:55.715 [info] Error parsing pth file:

2025-05-27 22:13:03.635 [info] [Info - 10:13:03 PM] (2536) BG: Indexer background runner(4) root directory: file:///c%3A/Users/hunte/.vscode-insiders/extensions/ms-python.vscode-pylance-2025.5.100/dist (index) 2025-05-27 22:13:03.637 [info] [Info - 10:13:03 PM] (2536) BG: Indexing(4) started 2025-05-27 22:13:03.919 [info] [Info - 10:13:03 PM] (2536) BG: scanned(4) 735 files over 1 exec env 2025-05-27 22:13:08.563 [info] [Info - 10:13:08 PM] (2536) BG: [IDX(4)] Long operation: index execution environment file:///c%3A/apps/astToolFactory (4052ms) 2025-05-27 22:13:08.564 [info] [Info - 10:13:08 PM] (2536) BG: [IDX(4)] Long operation: index packages file:///c%3A/apps/astToolFactory (4437ms) 2025-05-27 22:13:08.564 [info] [Info - 10:13:08 PM] (2536) BG: indexed(4) 735 files over 1 exec env 2025-05-27 22:13:08.792 [info] [Info - 10:13:08 PM] (2536) BG: Indexing finished(4). 2025-05-27 22:14:58.070 [info] [Info - 10:14:58 PM] (2536) Starting service instance "" for workspace "" 2025-05-27 22:14:58.167 [info] [Info - 10:14:58 PM] (2536) Setting environmentName for service "": "3.13.3 (.venv venv)" 2025-05-27 22:14:58.167 [info] [Info - 10:14:58 PM] (2536) Setting pythonPath for service "": "c:\apps\astToolFactory.venv\Scripts\python.exe" 2025-05-27 22:14:58.168 [info] [Info - 10:14:58 PM] (2536) No include entries specified; assuming <default workspace root> 2025-05-27 22:14:58.253 [info] [Info - 10:14:58 PM] (2536) Assuming Python version 3.13.3.final.0 2025-05-27 22:14:58.375 [info] [Error - 10:14:58 PM] (2536) File or directory "<default workspace root>" does not exist. 2025-05-27 22:14:58.376 [info] [Info - 10:14:58 PM] (2536) No source files found. 2025-05-27 22:14:58.971 [info] [Info - 10:14:58 PM] (2536) BG: Priority queue background worker(6) root directory: file:///c%3A/Users/hunte/.vscode-insiders/extensions/ms-python.vscode-pylance-2025.5.100/dist 2025-05-27 22:14:58.977 [info] [Info - 10:14:58 PM] (2536) BG: Priority queue background worker(6) started

Extension version: 2025.5.100 VS Code version: Code - Insiders 1.101.0-insider (9bb394b245ee20e869120eefdc6929c580029adf, 2025-05-27T06:34:19.809Z) OS version: Windows_NT x64 10.0.26100 Modes:

System Info
Item Value
CPUs AMD Ryzen 7 5700U with Radeon Graphics (16 x 1797)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 12.90GB (2.38GB free)
Process Argv --crash-reporter-id 1ffa83f2-6d65-4589-b9e5-f941a87a12e2
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt551:31249597
vscod805cf:30301675
c4g48928:30535728
962ge761:30841072
dsvsc014:30777825
dsvsc015:30821418
h48ei257:31000450
pythontbext0:30879054
cppperfnew:30980852
dwnewjupyter:31046869
pythonrstrctxt:31093868
nativeloc1:31118317
e80f6927:31120813
dwcopilot:31158714
5b1c1929:31184661
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
g012b348:31231168
pythoneinst12:31251391
bgtreat:31252123
c7cif404:31309980
pythonpulldiag:31287486
6gi0g917:31259950
61ibe868:31282443
996jf627:31264550
pythonrdcb7:31268811
usemplatestapi:31297334
e6194696:31309975
747dc170:31275146
pythonfullctx:31296836
6518g693:31302842
pylancecolor:31288664
generatesymbolt:31280541
convertfstringf:31280702
gendocf:31280703
pylancequickfixt:31311477
923gi514:31310909
b99bg931:31306656
je023986:31315494
a2ijf515:31307742
convertlamdat:31311571
67ih8103:31315085
gce3e431:31315077

hunterhogan avatar May 28 '25 03:05 hunterhogan

Hi @hunterhogan, I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.


Potentially Related Issues

  • Support path (*.pth) files in extra paths: discussion on scanning .pth files under extraPaths (#1709)
    https://github.com/microsoft/pylance-release/issues/1709
  • Crash on .pth referencing .egg: Pylance crashes when parsing a .pth that points to an .egg (#5009)
    https://github.com/microsoft/pylance-release/issues/5009

The team will respond to your issue shortly. Please note this is a trial feature and may not be fully accurate. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or was incorrect, please give it a 👎. Your feedback helps us improve!

github-actions[bot] avatar May 28 '25 03:05 github-actions[bot]

Hi @hunterhogan, I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.

Potentially Related Issues

* Support path (*.pth) files in extra paths: discussion on scanning `.pth` files under `extraPaths` ([Support path (*.pth) files in extra paths #1709](https://github.com/microsoft/pylance-release/issues/1709))
  [Support path (*.pth) files in extra paths #1709](https://github.com/microsoft/pylance-release/issues/1709)

* Crash on `.pth` referencing `.egg`: Pylance crashes when parsing a `.pth` that points to an `.egg` ([Pylance crashed immediately after open VSCode #5009](https://github.com/microsoft/pylance-release/issues/5009))
  [Pylance crashed immediately after open VSCode #5009](https://github.com/microsoft/pylance-release/issues/5009)

The team will respond to your issue shortly. Please note this is a trial feature and may not be fully accurate. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or was incorrect, please give it a 👎. Your feedback helps us improve!

Thank you for wasting my time.

hunterhogan avatar May 28 '25 03:05 hunterhogan

(.venv) C:\apps\astToolFactory>py
Python 3.13.3 (tags/v3.13.3:6280bb5, Apr  8 2025, 14:47:33) [MSC v.1943 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from os import add_dll_directory
>>> 

hunterhogan avatar May 28 '25 15:05 hunterhogan

Oh I bet I know what the problem is. Pywin32 is using Win32 only functions. The pth eval stuff is using the WASI version of python to run the pth file and it is actually a linux build of CPython.

Pth support doesn't work with pywin32. We might want to special case this scenario.

os.add_dll_directory is windows only:

https://docs.python.org/3/library/os.html#os.add_dll_directory

rchiodo avatar May 28 '25 16:05 rchiodo

Thanks for creating the issue but it shouldn't impact functionality in anyway. The error just points out we may not be able to load some pth files.

rchiodo avatar May 28 '25 16:05 rchiodo

(.venv) C:\apps\astToolFactory>pip show pywin32
Name: pywin32
Version: 310
Summary: Python for Window Extensions
Home-page: https://github.com/mhammond/pywin32
Author: Mark Hammond (et al)
Author-email: [email protected]
License: PSF
Location: C:\apps\astToolFactory\.venv\Lib\site-packages
Requires: 
Required-by: jupyter_core

idk if I installed it, so: del venv, py -m venv, upgrade pip, pip install -e .[testing]. restart vs code. therefore, a clean slate.


(.venv) C:\apps\astToolFactory>ver

Microsoft Windows [Version 10.0.26100.4061]

(.venv) C:\apps\astToolFactory>py -V  
Python 3.13.3

(.venv) C:\apps\astToolFactory>pip show pywin32
WARNING: Package(s) not found: pywin32

repo at the exact commit I'm using locally https://github.com/hunterhogan/astToolFactory/commit/9434c936ec308b68eebc9dfe55fdc61b10cbc984 including install file (above) and notebook (below)

I don't do anything else at all in vs code or the repo. open notebook, run cell: prompted to install kernel. install.

(.venv) C:\apps\astToolFactory>pip show pywin32
Name: pywin32
Version: 310
Summary: Python for Window Extensions
Home-page: https://github.com/mhammond/pywin32
Author: Mark Hammond (et al)
Author-email: [email protected]
License: PSF
Location: C:\apps\astToolFactory\.venv\Lib\site-packages
Requires: 
Required-by: jupyter_core

Therefore, it was installed by VS Code. and the errors are back in the log.

every.log

hunterhogan avatar May 29 '25 02:05 hunterhogan

The errors are not going to affect anything though. They're just an indicator to us that there's a pth file we can't load. The error should have no impact on functionality.

I'm leaving the bug open so we can stop checking this particular pth file and stop polluting the log.

rchiodo avatar May 29 '25 16:05 rchiodo