🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 138 (from laksa166)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
CRAWLED
1 day ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.pythonhello.com/practice/python-relative-and-absolute-import
Last Crawled2026-04-06 11:01:24 (1 day ago)
First Indexed2023-01-27 09:14:16 (3 years ago)
HTTP Status Code200
Meta Titlenull
Meta Descriptionnull
Meta Canonicalnull
Boilerpipe Text
In Python, there are two types of imports: relative and absolute Relative Imports Relative imports allow you to import Python modules that are located in a different directory from the current Python script. Relative imports are specified using the . notation. For example, if you have the following file structure: project/ main.py module1/ __init__.py script1.py You can import script1.py from main.py using a relative import: # main.py from .module1 import script1 The . notation indicates that script1.py is located in a subdirectory of the current directory. The number of dots used in the import statement indicates the level of the subdirectory. For example, if main.py and module1 are located in the same directory and you want to import script1.py from main.py, you can use a single dot: # main.py from . import script1 If main.py is located in a subdirectory of module1, you can use two dots to specify the parent directory: # main.py from .. import script1 Absolute Imports Absolute imports, on the other hand, allow you to import Python modules from the root directory of your project. Absolute imports specify the full path to a module, starting from the root directory of your project. For example, for the same file structure as above, you can import script1.py from main.py using an absolute import: # main.py from module1 import script1 Common Pitfalls Most of the common pitfalls involve statements with relative imports: Importing a module from a different directory using a relative import may not work if the module is not located in a package (i.e., a directory with an init .py file). Using a relative import to import a module from a different directory may not work if the current Python script is located outside of the project directory. Importing a module using an absolute import may not work if the module is located in a different Python path (e.g., a different virtual environment or a system-wide Python installation). If you use a relative import and then move your Python script to a different directory, the import may break because the relative path to the module will be different.
Markdown
[Skip to content](https://www.pythonhello.com/practice/python-relative-and-absolute-import#skip-nav) Learn Fundamentals In Practice Guides Additional Common Problems [Articles](https://www.pythonhello.com/articles) [![logo](https://www.pythonhello.com/PythonHelloLogo.png)](https://www.pythonhello.com/) [![logo](https://www.pythonhello.com/PythonHelloLogo.png)](https://www.pythonhello.com/) [Fundamentals](https://www.pythonhello.com/fundamentals/welcome)[In Practice Guides](https://www.pythonhello.com/practice/welcome)[Common Problems](https://www.pythonhello.com/problems)[Exercises](https://www.pythonhello.com/practice/python-relative-and-absolute-import) [Buy me a Coffee](https://www.buymeacoffee.com/pythonhello) General - [Meaningful Names](https://www.pythonhello.com/practice/python-meaningful-names) Python Project Structure - [Python Modules](https://www.pythonhello.com/practice/python-modules) - [Import Modules](https://www.pythonhello.com/practice/python-import-modules) - [Relative & Absolute Import](https://www.pythonhello.com/practice/python-relative-and-absolute-import) Python Debugging - [Debugging](https://www.pythonhello.com/practice/python-debugging) - [Advanced Debugging](https://www.pythonhello.com/practice/python-advanced-debugging) Python Testing - [Python Unit Tests](https://www.pythonhello.com/practice/python-unit-tests) - [Write Unit Tests](https://www.pythonhello.com/practice/python-write-unit-test) - [Unit Test Patterns](https://www.pythonhello.com/practice/python-unit-tests-patterns) - [Pytest](https://www.pythonhello.com/practice/python-pytest) - [Pytest Fixtures](https://www.pythonhello.com/practice/python-pytest-fixtures) - [Pytest Built-In Fixtures](https://www.pythonhello.com/practice/python-pytest-built-in-fixtures) Python Typing - [Typing in Python](https://www.pythonhello.com/practice/python-typing) - [Typing module](https://www.pythonhello.com/practice/python-typing-module) - [Concrete Collections Types](https://www.pythonhello.com/practice/python-concrete-types) Home / Fundamentals # Python Relative & Absolute Import In Python, there are two types of imports: relative and absolute [Relative Imports](https://www.pythonhello.com/practice/python-relative-and-absolute-import#relative-imports) Relative imports allow you to import Python modules that are located in a different directory from the current Python script. Relative imports are specified using the . notation. For example, if you have the following file structure: ``` project/ main.py module1/ __init__.py script1.py ``` You can import `script1.py` from main.py using a relative import: ``` # main.py from .module1 import script1 ``` The . notation indicates that script1.py is located in a subdirectory of the current directory. The number of dots used in the import statement indicates the level of the subdirectory. For example, if main.py and module1 are located in the same directory and you want to import script1.py from main.py, you can use a single dot: ``` # main.py from . import script1 ``` If main.py is located in a subdirectory of module1, you can use two dots to specify the parent directory: ``` # main.py from .. import script1 ``` [Absolute Imports](https://www.pythonhello.com/practice/python-relative-and-absolute-import#absolute-imports) Absolute imports, on the other hand, allow you to import Python modules from the root directory of your project. Absolute imports specify the full path to a module, starting from the root directory of your project. For example, for the same file structure as above, you can import script1.py from main.py using an absolute import: ``` # main.py from module1 import script1 ``` [Common Pitfalls](https://www.pythonhello.com/practice/python-relative-and-absolute-import#common-pitfalls) Most of the common pitfalls involve statements with relative imports: - Importing a module from a different directory using a relative import may not work if the module is not located in a package (i.e., a directory with an **init**.py file). - Using a relative import to import a module from a different directory may not work if the current Python script is located outside of the project directory. - Importing a module using an absolute import may not work if the module is located in a different Python path (e.g., a different virtual environment or a system-wide Python installation). - If you use a relative import and then move your Python script to a different directory, the import may break because the relative path to the module will be different. [Home](https://www.pythonhello.com/) [Fundamentals Tutorial](https://www.pythonhello.com/fundamentals/welcome) [In-Practice Guides](https://www.pythonhello.com/practice/welcome) [Resources](https://www.pythonhello.com/resources) PythonHello is an online tutorial. The articles, examples and references are continuously reviewed to provide the best experience, but we cannot warrant full correctness of all content. Feedback is much welcomed. You can [contact us here](https://www.pythonhello.com/contact-us) [![instagram logo handle](https://www.pythonhello.com/instagram.png)](https://www.instagram.com/pythonhello/) © 2025 PythonHello. All Rights Reserved. Read our [Terms of Use](https://www.pythonhello.com/terms-and-conditions) and [Privacy Policy](https://www.pythonhello.com/privacy-policy)
Readable Markdown
In Python, there are two types of imports: relative and absolute [Relative Imports](https://www.pythonhello.com/practice/python-relative-and-absolute-import#relative-imports) Relative imports allow you to import Python modules that are located in a different directory from the current Python script. Relative imports are specified using the . notation. For example, if you have the following file structure: ``` project/ main.py module1/ __init__.py script1.py ``` You can import `script1.py` from main.py using a relative import: ``` # main.py from .module1 import script1 ``` The . notation indicates that script1.py is located in a subdirectory of the current directory. The number of dots used in the import statement indicates the level of the subdirectory. For example, if main.py and module1 are located in the same directory and you want to import script1.py from main.py, you can use a single dot: ``` # main.py from . import script1 ``` If main.py is located in a subdirectory of module1, you can use two dots to specify the parent directory: ``` # main.py from .. import script1 ``` [Absolute Imports](https://www.pythonhello.com/practice/python-relative-and-absolute-import#absolute-imports) Absolute imports, on the other hand, allow you to import Python modules from the root directory of your project. Absolute imports specify the full path to a module, starting from the root directory of your project. For example, for the same file structure as above, you can import script1.py from main.py using an absolute import: ``` # main.py from module1 import script1 ``` [Common Pitfalls](https://www.pythonhello.com/practice/python-relative-and-absolute-import#common-pitfalls) Most of the common pitfalls involve statements with relative imports: - Importing a module from a different directory using a relative import may not work if the module is not located in a package (i.e., a directory with an **init**.py file). - Using a relative import to import a module from a different directory may not work if the current Python script is located outside of the project directory. - Importing a module using an absolute import may not work if the module is located in a different Python path (e.g., a different virtual environment or a system-wide Python installation). - If you use a relative import and then move your Python script to a different directory, the import may break because the relative path to the module will be different.
Shard138 (laksa)
Root Hash12730255415513514138
Unparsed URLcom,pythonhello!www,/practice/python-relative-and-absolute-import s443