Skip to content

3.14 not adding cwd to sys.path() on Windows breaking local imports #141178

@defkev

Description

@defkev

Bug report

Bug description:

Project:

main.py
foo/__init__.py
foo/bar.py

main.py

import sys
print(sys.path)

from foo import bar

stdout:

['C:\\python-3.14.0-embed-amd64\\python314.zip', 'C:\\python-3.14.0-embed-amd64', 'C:\\python-3.14.0-embed-amd64\\Lib\\site-packages']
Traceback (most recent call last):
  File "main.py", line 4, in <module>
    from foo import bar
ModuleNotFoundError: No module named 'foo'

C:\\python-3.14.0-embed-amd64\\ is in %PATH%

Adding the project folder to sys.path at runtime obviously fixes the problem.

This definitely used to work w/o any workarounds up until at least 3.11 and still works with the free-threaded Python 3.14 build distributed by nuget (https://www.nuget.org/packages/python-freethreaded) so it's more a problem with the binary from https://www.python.org/downloads/windows/ than cpython.

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions