1

Let's suppose I import the pathlib module with an alias :

import pathlib as plib

Then plib is now pointing to the pathlib module :

>>> plib
<module 'pathlib' from '/usr/lib/python3.8/pathlib.py'>

Now can someone tell me why importing something from this aliased module doesn't work?

>>> from plib import Path
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'plib'
johhnry
  • 29
  • 1
  • 4

1 Answers1

1

The loading process of The module is not based on the alias, it searches the python installation or project directory by the given name after import statement.

Wasif
  • 14,755
  • 3
  • 14
  • 34