Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
My working directory is under MyProject, which includes an __init__.py file and other necessary files to be recognized as a package.
But when I try to run the code from . import * in the shell using Python, there are two different outcomes in the two invocation methods (argument passing and REPL execution).
The folder looks like:
├── main.py
├── init.py
├── _implements.py
└── code.py
(PythonProject) C:\Users\KrisT\Desktop\PythonProject>python -c "from . import *" Traceback (most recent call last): File "<string>", line 1, in<module> from . import * ImportError: attempted relative import with no known parent package (PythonProject) C:\Users\KrisT\Desktop\PythonProject>python -q >>> import sys;print(sys.version_info) sys.version_info(major=3, minor=13, micro=1, releaselevel='final', serial=0) >>> from . import * >>> dir() ['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'commands', 'completing_reader', 'console', 'historical_reader', 'input', 'keymap', 'main', 'reader', 'readline', 'simple_interact', 'sys', 'trace', 'types', 'utils', 'windows_console'] >>> print(console) <module '_pyrepl.console' from 'E:\\Python\\Lib\\_pyrepl\\console.py'> >>> print(input) <module '_pyrepl.input' from 'E:\\Python\\Lib\\_pyrepl\\input.py'> >>> print(keymap) <module '_pyrepl.keymap' from 'E:\\Python\\Lib\\_pyrepl\\keymap.py'> >>>It loaded the _pyrepl package instead of my PythonProject.
CPython versions tested on:
3.13
Operating systems tested on:
Windows
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error