🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 71 (from laksa021)

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
6 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.2 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://realpython.com/videos/absolute-vs-relative-imports-python-overview/
Last Crawled2026-04-11 04:35:03 (6 days ago)
First Indexed2024-11-21 14:48:13 (1 year ago)
HTTP Status Code200
Meta TitleAbsolute vs Relative Imports in Python: Overview (Video) – Real Python
Meta DescriptionHello! And welcome to the Real Python guide to Absolute vs Relative Imports in Python. In this set of videos, you’re going to learn the difference between absolute and relative imports as well as when to use each method. While this course does…
Meta Canonicalnull
Boilerpipe Text
If you’ve worked on a Python project that has more than one file, chances are you’ve had to use an import statement before. Even for Pythonistas with a couple of projects under their belt, imports can be confusing! If you’re reading this because you’d like to gain a deeper understanding of imports in Python, particularly absolute and relative imports , then you’ve come to the right place! In this tutorial, you’ll learn the differences between the two, as well as their pros and cons. 00:00 Hello! And welcome to the Real Python guide to Absolute vs Relative Imports in Python. In this set of videos, you’re going to learn the difference between absolute and relative imports as well as when to use each method. 00:13 While this course does assume a bit of knowledge on modules and packages in Python, you’ll first do a quick recap before getting started. Next, you’ll see how absolute imports work, followed by how relative imports work. 00:27 So, why do you import things? Once your projects start getting larger and larger, it can be helpful to split your code into multiple files. Imports allow you to carry functionality between files, including things that you didn’t even write. If you pip install something, then you have to import it before you can use it. For the scope of this course, a module is a Python file that ends in .py , while a package is a collection of modules in a folder. The distinction isn’t too critical for this, but it will help when we get to the examples. 00:59 When you import something, Python has a couple of places to look. First, it looks in the sys.modules cache, which is where everything that was previously imported is kept. 01:10 If something is already in here— maybe you imported it from another script in your project— there’s no need to read another module into the cache. If it’s not there, Python then checks the standard library. This is where things like os , json , and csv are kept. 01:26 Anything that you don’t need to pip install is generally kept here. Finally, Python will look in the sys.path . This is a list of directories which usually includes the current directory. 01:39 Any local files that you write for your application should be located here. This is where absolute and relative imports become very important. If Python looks through all these places and still doesn’t find it, then you’ll get the ModuleNotFoundError , which generally means you either made a typo, didn’t install something, or are directing Python to look in the wrong area. 02:02 Keep in mind that this order is very specific and can have a couple security concerns. sys.modules is a writeable cache, so there is a chance that unexpected code could be imported into your project. 02:14 If you’re familiar with the DLL hijacking on Windows machines, this is a similar concept and something to keep in mind depending on your application’s use case. To perform an import, you have a couple of different options. 02:27 The most standard way is to just say import and then put the name of the module that you’d like to bring in. This would bring in all of csv . 02:36 If you don’t need the entire package or module, you can import a resource directly from it by saying from and then importing what you need. In this case, Flask with a capital F is a class from the flask package. 02:50 Finally, with whatever you’re importing, you have the option to rename it. So here, while you’re importing all of pandas , you’re importing it as pd so that you can refer to it in your code as pd . 03:04 Finally, PEP 8 has some guidelines for styling your imports. 03:09 Always keep them at the top of your file after any module comments or docstrings 03:14 and then divide them up based on what’s being imported. A good way to break them up is getting anything from the standard library first, 03:23 then any third-party imports that you need, followed by any of your application local imports. Within each of these groups, it’s helpful to keep everything alphabetical so that if there’s a lot of imports, it can be easy to find things later on. And, separate out each of these groups with a blank line. All right! That’s it for the refresher, and now you’re all set to start learning the differences between absolute and relative imports. Thanks for watching.
Markdown
[![Real Python](https://realpython.com/static/real-python-logo.893c30edea53.svg)](https://realpython.com/) - [Start Here](https://realpython.com/start-here/) - [Learn Python](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/) [Python Tutorials → In-depth articles and video courses](https://realpython.com/search?kind=article&kind=course&order=newest) [Learning Paths → Guided study plans for accelerated learning](https://realpython.com/learning-paths/) [Quizzes & Exercises → Check your learning progress](https://realpython.com/quizzes/) [Browse Topics → Focus on a specific area or skill level](https://realpython.com/tutorials/all/) [Community Chat → Learn with other Pythonistas](https://realpython.com/community/) [Office Hours → Live Q\&A calls with Python experts](https://realpython.com/office-hours/) [Live Courses → Live, instructor-led Python courses](https://realpython.com/live/) [Podcast → Hear what’s new in the world of Python](https://realpython.com/podcasts/rpp/) [Books → Round out your knowledge and learn offline](https://realpython.com/products/books/) [Reference → Concise definitions for common Python terms](https://realpython.com/ref/) [Code Mentor →Beta Personalized code assistance & learning tools](https://realpython.com/mentor/) [Unlock All Content →](https://realpython.com/account/join/) - [More](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/) [Learner Stories](https://realpython.com/learner-stories/) [Python Newsletter](https://realpython.com/newsletter/) [Python Job Board](https://www.pythonjobshq.com/) [Meet the Team](https://realpython.com/team/) [Become a Contributor](https://realpython.com/jobs/) - [Search](https://realpython.com/search "Search") - [Join](https://realpython.com/account/join/) - [Sign‑In](https://realpython.com/account/login/?next=%2Fvideos%2Fabsolute-vs-relative-imports-python-overview%2F) Exit Fullscreen Loading video player… # Absolute vs Relative Imports in Python: Overview [![Joe Tatusko](https://realpython.com/cdn-cgi/image/width=1361,height=1361,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/century.d2e9b3c6afef.jpg)](https://realpython.com/courses/absolute-vs-relative-imports-python/#team) **[Absolute vs Relative Imports in Python](https://realpython.com/courses/absolute-vs-relative-imports-python/)** [Joe Tatusko](https://realpython.com/courses/absolute-vs-relative-imports-python/#team) 03:54 Mark as Completed Supporting Material [Recommended Tutorial](https://realpython.com/absolute-vs-relative-python-imports/) [Ask a Question](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#discussion) - [Contents](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#description) - [Transcript](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#transcript) - [Discussion (5)](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#discussion) If you’ve worked on a Python project that has more than one file, chances are you’ve had to use an `import` statement before. Even for Pythonistas with a couple of projects under their belt, imports can be confusing\! If you’re reading this because you’d like to gain a deeper understanding of imports in Python, particularly **absolute** and **relative imports**, then you’ve come to the right place! In this tutorial, you’ll learn the differences between the two, as well as their pros and cons. [**00:00**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=0.63) [Hello\!](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=0.63) [And welcome to the Real Python guide to Absolute vs Relative Imports in](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=1.62) [Python. In this set of videos,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=5.34) [you’re going to learn the difference between absolute and relative imports](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=7.98) [as well as when to use each method.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=11.31) [**00:13**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=13.86) [While this course does assume a bit of knowledge on modules and packages](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=13.86) [in Python, you’ll first do a quick recap before getting started. Next,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=17.1) [you’ll see how absolute imports work, followed by how relative imports work.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=22.5) [**00:27**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=27.86) [So, why do you import things? Once your projects start getting larger and larger,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=27.86) [it can be helpful to split your code into multiple files.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=32.18) [Imports allow you to carry functionality between files,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=35.48) [including things that you didn’t even write. If you `pip install` something,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=38.72) [then you have to import it before you can use it. For the scope of this course,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=42.5) [a module is a Python file that ends in `.py`,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=47.45) [while a package is a collection of modules in a folder. The distinction isn’t too](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=51.56) [critical for this, but it will help when we get to the examples.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=55.79) [**00:59**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=59.21) [When you import something, Python has a couple of places to look.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=59.21) [First, it looks in the `sys.modules` cache,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=62.93) [which is where everything that was previously imported is kept.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=66.98) [**01:10**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=70.48) [If something is already in here—](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=70.48)[maybe you imported it from another script in your project—](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=72.2)[there’s no need to read another module into the cache. If it’s not there,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=74.96) [Python then checks the standard library. This is where things like](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=79.79) [`os`, `json`, and `csv` are kept.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=83.59) [**01:26**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=86.75) [Anything that you don’t need to `pip install` is generally kept here. Finally,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=86.75) [Python will look in the `sys.path`. This is a list of directories](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=91.88) [which usually includes the current directory.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=96.56) [**01:39**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=99.2) [Any local files that you write for your application should be located here.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=99.2) [This is where absolute and relative imports become very important.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=103.76) [If Python looks through all these places and still doesn’t find it,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=108.05) [then you’ll get the `ModuleNotFoundError`,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=111.44) [which generally means you either made a typo,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=114.11) [didn’t install something, or are directing Python to look in the wrong area.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=117.44) [**02:02**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=122.12) [Keep in mind that this order is very specific and can have a couple security](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=122.12) [concerns. `sys.modules` is a writeable cache,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=125.78) [so there is a chance that unexpected code could be imported into your project.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=130.07) [**02:14**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=134.57) [If you’re familiar with the DLL hijacking on Windows machines, this is a similar concept](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=134.57) [and something to keep in mind](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=139.52) [depending on your application’s use case. To perform an import,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=140.78) [you have a couple of different options.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=145.25) [**02:27**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=147.68) [The most standard way is to just say `import` and then put the name of the module](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=147.68) [that you’d like to bring in. This would bring in all of `csv`.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=152.06) [**02:36**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=156.59) [If you don’t need the entire package or module,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=156.59) [you can import a resource directly from it by saying `from`](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=159.26) [and then importing what you need. In this case,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=162.83) [`Flask` with a capital `F` is a class from the `flask` package.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=166.43) [**02:50**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=170.96) [Finally, with whatever you’re importing, you have the option to rename it.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=170.96) [So here, while you’re importing all of `pandas`,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=175.52) [you’re importing it `as pd` so that you can refer to it in your code as `pd`.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=178.16) [**03:04**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=184.72) [Finally, PEP 8 has some guidelines for styling your imports.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=184.72) [**03:09**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=189.34) [Always keep them at the top of your file after any module comments or docstrings](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=189.34) [**03:14**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=194.98) [and then divide them up based on what’s being imported. A good way to break them](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=194.98) [up is getting anything from the standard library first,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=199.9) [**03:23**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=203.62) [then any third-party imports that you need, followed by any of your application](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=203.62) [local imports. Within each of these groups,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=208.9) [it’s helpful to keep everything alphabetical so that if there’s a lot of imports,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=212.77) [it can be easy to find things later on. And, separate out each of these groups](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=216.97) [with a blank line. All right! That’s it for the refresher,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=221.59) [and now you’re all set to start learning the differences between absolute and](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=226.03) [relative imports. Thanks for watching.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=229.3) ![Avatar image for FP](https://www.gravatar.com/avatar/633422b6003644ce07ffdbdbda797d3c?s=500&d=mp) **FP** on [Sept. 15, 2019](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#comment-18bf2f54-ca40-4dd8-bf9b-cb18cd047bc1) Videos playing but no audio. ![Avatar image for Dan Bader](https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/daniel-square.d58bf4388750.jpg) **Dan Bader** RP Team on [Sept. 16, 2019](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#comment-f55e6ad5-b547-4518-b000-db7e47e07fe9) Sorry folks, I can’t seem to be able to reproduce this—the videos are playing fine on my end (tested in various browsers). I recommend you check out our [“video playback issues” troubleshooting docs](https://support.realpython.com/article/23-how-to-troubleshoot-video-playback-issues). ![Avatar image for Looney](https://www.gravatar.com/avatar/2c9bbaba3001e158453e54c513881467?s=500&d=mp) **Looney** on [Sept. 18, 2019](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#comment-bd91a880-3b85-4817-8a81-009618437efd) what can be the use cases where we should add our package in sys.module . ? ![Avatar image for Joe Tatusko](https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/century.d2e9b3c6afef.jpg) **Joe Tatusko** RP Team on [Sept. 18, 2019](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#comment-eb61a62c-c4e3-431c-876a-370bead49f29) Manipulating sys.modules isn’t something you normally have to think about. That is where any module that has been previously imported is stored, so you add modules and packages to it just by importing them. It might help to think about it this way: ``` ``` In this example, the first time you import pandas Python is going to look in the sys.modules cache, and not find it (assuming this is the only script that is running). It then looks in the built in modules, and then will look in sys.path for the location of pandas. When you try to import it a second time, Python is able to find it in sys.modules, so it doesn’t need to continue searching or load it again. ![Avatar image for Looney](https://www.gravatar.com/avatar/2c9bbaba3001e158453e54c513881467?s=500&d=mp) **Looney** on [Sept. 19, 2019](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#comment-657be240-f0d3-44f7-af1a-9fe6ace2982d) Thanks for explanation. [Become a Member](https://realpython.com/account/join/) to join the conversation. Course Contents [Overview](https://realpython.com/courses/absolute-vs-relative-imports-python/) 25% © 2012–2026 Real Python ⋅ [Privacy Policy](https://realpython.com/privacy-policy/) ![](https://www.facebook.com/tr?id=2220911568135371&ev=PageView&noscript=1)
Readable Markdown
If you’ve worked on a Python project that has more than one file, chances are you’ve had to use an `import` statement before. Even for Pythonistas with a couple of projects under their belt, imports can be confusing\! If you’re reading this because you’d like to gain a deeper understanding of imports in Python, particularly **absolute** and **relative imports**, then you’ve come to the right place! In this tutorial, you’ll learn the differences between the two, as well as their pros and cons. [**00:00**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=0.63) [Hello\!](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=0.63) [And welcome to the Real Python guide to Absolute vs Relative Imports in](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=1.62) [Python. In this set of videos,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=5.34) [you’re going to learn the difference between absolute and relative imports](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=7.98) [as well as when to use each method.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=11.31) [**00:13**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=13.86) [While this course does assume a bit of knowledge on modules and packages](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=13.86) [in Python, you’ll first do a quick recap before getting started. Next,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=17.1) [you’ll see how absolute imports work, followed by how relative imports work.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=22.5) [**00:27**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=27.86) [So, why do you import things? Once your projects start getting larger and larger,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=27.86) [it can be helpful to split your code into multiple files.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=32.18) [Imports allow you to carry functionality between files,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=35.48) [including things that you didn’t even write. If you `pip install` something,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=38.72) [then you have to import it before you can use it. For the scope of this course,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=42.5) [a module is a Python file that ends in `.py`,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=47.45) [while a package is a collection of modules in a folder. The distinction isn’t too](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=51.56) [critical for this, but it will help when we get to the examples.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=55.79) [**00:59**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=59.21) [When you import something, Python has a couple of places to look.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=59.21) [First, it looks in the `sys.modules` cache,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=62.93) [which is where everything that was previously imported is kept.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=66.98) [**01:10**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=70.48) [If something is already in here—](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=70.48)[maybe you imported it from another script in your project—](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=72.2)[there’s no need to read another module into the cache. If it’s not there,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=74.96) [Python then checks the standard library. This is where things like](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=79.79) [`os`, `json`, and `csv` are kept.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=83.59) [**01:26**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=86.75) [Anything that you don’t need to `pip install` is generally kept here. Finally,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=86.75) [Python will look in the `sys.path`. This is a list of directories](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=91.88) [which usually includes the current directory.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=96.56) [**01:39**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=99.2) [Any local files that you write for your application should be located here.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=99.2) [This is where absolute and relative imports become very important.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=103.76) [If Python looks through all these places and still doesn’t find it,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=108.05) [then you’ll get the `ModuleNotFoundError`,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=111.44) [which generally means you either made a typo,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=114.11) [didn’t install something, or are directing Python to look in the wrong area.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=117.44) [**02:02**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=122.12) [Keep in mind that this order is very specific and can have a couple security](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=122.12) [concerns. `sys.modules` is a writeable cache,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=125.78) [so there is a chance that unexpected code could be imported into your project.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=130.07) [**02:14**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=134.57) [If you’re familiar with the DLL hijacking on Windows machines, this is a similar concept](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=134.57) [and something to keep in mind](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=139.52) [depending on your application’s use case. To perform an import,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=140.78) [you have a couple of different options.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=145.25) [**02:27**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=147.68) [The most standard way is to just say `import` and then put the name of the module](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=147.68) [that you’d like to bring in. This would bring in all of `csv`.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=152.06) [**02:36**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=156.59) [If you don’t need the entire package or module,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=156.59) [you can import a resource directly from it by saying `from`](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=159.26) [and then importing what you need. In this case,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=162.83) [`Flask` with a capital `F` is a class from the `flask` package.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=166.43) [**02:50**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=170.96) [Finally, with whatever you’re importing, you have the option to rename it.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=170.96) [So here, while you’re importing all of `pandas`,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=175.52) [you’re importing it `as pd` so that you can refer to it in your code as `pd`.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=178.16) [**03:04**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=184.72) [Finally, PEP 8 has some guidelines for styling your imports.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=184.72) [**03:09**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=189.34) [Always keep them at the top of your file after any module comments or docstrings](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=189.34) [**03:14**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=194.98) [and then divide them up based on what’s being imported. A good way to break them](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=194.98) [up is getting anything from the standard library first,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=199.9) [**03:23**](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=203.62) [then any third-party imports that you need, followed by any of your application](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=203.62) [local imports. Within each of these groups,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=208.9) [it’s helpful to keep everything alphabetical so that if there’s a lot of imports,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=212.77) [it can be easy to find things later on. And, separate out each of these groups](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=216.97) [with a blank line. All right! That’s it for the refresher,](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=221.59) [and now you’re all set to start learning the differences between absolute and](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=226.03) [relative imports. Thanks for watching.](https://realpython.com/videos/absolute-vs-relative-imports-python-overview/#t=229.3)
Shard71 (laksa)
Root Hash13351397557425671
Unparsed URLcom,realpython!/videos/absolute-vs-relative-imports-python-overview/ s443