|
| https://realpython.com/ |
| Start Here | https://realpython.com/start-here/ |
|
Learn Python
| https://realpython.com/lessons/scripts-modules-packages-and-libraries |
| 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/ |
| 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 →BetaPersonalized code assistance & learning tools | https://realpython.com/mentor/ |
| Unlock All Content → | https://realpython.com/account/join/ |
|
More
| https://realpython.com/lessons/scripts-modules-packages-and-libraries |
| 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 Tutorial Writer | https://realpython.com/write-for-us/ |
| Become a Video Instructor | https://realpython.com/become-an-instructor/ |
| Search | https://realpython.com/search |
| https://realpython.com/search |
| Join | https://realpython.com/account/join/ |
| Sign‑In | https://realpython.com/account/login/?next=%2Fvideos%2Fscripts-modules-packages-and-libraries%2F |
| https://realpython.com/courses/what-is-pip/#team |
| A Beginner's Guide to pip | https://realpython.com/courses/what-is-pip/ |
| Austin Cepalia | https://realpython.com/courses/what-is-pip/#team |
| Recommended Tutorial | https://realpython.com/what-is-pip/ |
| Ask a Question | https://realpython.com/lessons/scripts-modules-packages-and-libraries#discussion |
| https://realpython.com/feedback/survey/course/what-is-pip/liked/?from=lesson-title |
| https://realpython.com/feedback/survey/course/what-is-pip/disliked/?from=lesson-title |
| Contents | https://realpython.com/lessons/scripts-modules-packages-and-libraries#description |
| Transcript | https://realpython.com/lessons/scripts-modules-packages-and-libraries#transcript |
| Discussion (5) | https://realpython.com/lessons/scripts-modules-packages-and-libraries#discussion |
| Matplotlib | https://realpython.com/python-matplotlib-guide/ |
| sending emails | https://realpython.com/python-send-email/ |
| Python Modules and Packages: An Introduction | https://realpython.com/courses/python-modules-packages/ |
| 00:00 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=0.51 |
| Python uses a lot of fancy terminology that you may not be familiar with if | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=0.51 |
| you’re new to programming | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=5.79 |
| or if you come from a different language. Before Python, my background was | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=7.17 |
| primarily in C# and Microsoft’s .NET framework. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=12.27 |
| 00:16 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=16.92 |
| I remember trying to learn Python | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=16.92 |
| but being kind of confused by all of these buzzwords. My goal | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=19.08 |
| in this course is to clear up some of this so that it’s not confusing to you | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=23.85 |
| later on. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=28.08 |
| 00:30 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=30.57 |
| A Python script is best defined as a Python file that contains commands in | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=30.57 |
| logical order. For this to be considered a script, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=36.66 |
| the program should do something—really, anything—when it’s run through the Python | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=40.38 |
| interpreter. To better understand this, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=45.72 |
| take a look at these two programs. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=48.6 |
| 00:51 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=51.78 |
| Both programs contain a function that will return the sum of two values. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=51.78 |
| However, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=57.42 |
| only the program on the right will actually call that function and print its | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=58.17 |
| result. The file on the right is intended to be run directly, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=62.34 |
| so we can say that it’s a Python script. On the other hand, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=67.17 |
| the program on the left doesn’t look like it’s actually meant to do anything. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=71.91 |
| 01:16 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=76.2 |
| Running that file will not produce any sort of output, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=76.2 |
| since the function is never being called. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=79.47 |
| It’s not intended to be run directly. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=82.32 |
| The file on the left is better classified as a module. That’s because we can | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=85.32 |
| import it into other files to utilize its classes, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=91.14 |
| functions, variables, and other members it’s defined. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=95.34 |
| 01:40 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=100.5 |
| I’m going to change the program on the right so that instead of defining the add() | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=100.5 |
| function, we import it from the module on the left. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=105.12 |
| This has the effect of making the addition function on the left | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=109.29 |
| accessible to the script on the right. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=113.58 |
| 01:58 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=118.88 |
| So, long story short: scripts are intended to be run directly, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=118.88 |
| whereas modules are meant to be imported. Scripts | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=123.77 |
| often contain statements outside of the scope of any class or function, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=127.97 |
| whereas modules define classes, functions, variables, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=132.95 |
| and other members for use in scripts that import it. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=138.14 |
| 02:22 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=142.76 |
| The words script and module are often used interchangeably, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=142.76 |
| so be aware that you might see other people use them in ways that don’t strictly | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=146.81 |
| follow these definitions. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=151.64 |
| 02:35 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=155.63 |
| Packages are a collection of related modules. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=155.63 |
| A package can be an individual Python module, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=159.62 |
| but they’re most often a collection of multiple related modules that come | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=163.22 |
| bundled together. This here is the dateutil package, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=168.83 |
| which allows for performing advanced date-related operations. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=173.69 |
| 02:58 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=178.61 |
| It’s bundled in a folder called dateutil. Inside | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=178.61 |
| there are a bunch of individual modules as well as folders containing other | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=183.01 |
| modules, which can be imported into your Python scripts. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=188.65 |
| 03:13 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=193.33 |
| These are modules because they don’t do anything interesting on their own. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=193.33 |
| When you import one into your own script, nothing really happens. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=198.46 |
| You have to use something defined within the module, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=203.5 |
| such as a class, function, or a variable. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=207.16 |
| 03:31 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=211.15 |
| This special __init__ file tells Python that this is a package, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=211.15 |
| potentially containing more modules nested within subfolders. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=216.07 |
| 03:42 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=222.67 |
| We can’t talk about libraries without mentioning the Python standard library. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=222.67 |
| The Python standard library is a large collection of modules and packages that | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=228.46 |
| come bundled with your installation of Python. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=234.58 |
| 03:58 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=238.27 |
| That means that you don’t have to download them from anywhere— | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=238.27 |
| you can just import them into your scripts and start using them right away. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=242.2 |
| dateutil is an example of a standard library package, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=247.03 |
| but there are also others, like email and json. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=251.35 |
| 04:16 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=256.93 |
| The key takeaway here is that a lot of this is, to some extent, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=256.93 |
| subjective. Scripts are runnable Python programs that do something when executed. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=261.37 |
| Modules are Python files that are intended to be imported into scripts and other | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=268.57 |
| modules so that their defined members—like classes and functions—can be used. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=274.12 |
| 04:41 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=281.02 |
| Packages are a collection of related modules that aim to achieve a common goal. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=281.02 |
| Finally, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=286.92 |
| the Python standard library is a collection of packages and modules that can be | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=288.13 |
| used to access built-in functionality. In an ideal world, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=293.23 |
| you’d import any necessary modules into your Python scripts without any issues. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=297.79 |
| 05:04 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=304.06 |
| Unfortunately, that’s often not the case. In the next video, | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=304.06 |
| I’ll show you what to do when Python can’t find the module you’ve just | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=308.47 |
| installed. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=312.37 |
| Then, you’ll learn how to actually install them with Python’s package manager. | https://realpython.com/lessons/scripts-modules-packages-and-libraries#t=313.6 |
| May 26, 2020 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#comment-193a9dc5-5cd2-4166-bdc3-b01589780186 |
| March 8, 2022 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#comment-3f0c2f31-a48e-4873-bc5f-56108eb06bf6 |
| March 9, 2022 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#comment-a5b6a464-a816-4a5d-97bb-00db35700bb8 |
| July 12, 2022 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#comment-2fab69ac-df2e-4f63-8434-dd53b9ab08da |
| July 12, 2022 | https://realpython.com/lessons/scripts-modules-packages-and-libraries#comment-520f3add-654f-44fb-a73d-80aea185a251 |
| Become a Member | https://realpython.com/account/join/ |
| https://realpython.com/videos/what-is-pip-overview/ |
| Overview | https://realpython.com/courses/what-is-pip/ |
| https://realpython.com/videos/why-cant-python-find-my-modules/ |
|
A Beginner's Guide to pip (Overview) 02:37
| https://realpython.com/videos/what-is-pip-overview/ |
|
Scripts, Modules, Packages, and Libraries 05:20
| https://realpython.com/videos/scripts-modules-packages-and-libraries/ |
|
Why Can't Python Find My Modules? 06:40
| https://realpython.com/videos/why-cant-python-find-my-modules/ |
|
What Is a Package Manager? 01:55
| https://realpython.com/lessons/what-package-manager/ |
|
Getting Started With pip and PyPI 07:15
| https://realpython.com/lessons/getting-started-pip-and-pypi/ |
|
Using Requirement Files 04:04
| https://realpython.com/lessons/using-requirement-files/ |
|
Production vs Development Dependencies 03:11
| https://realpython.com/lessons/production-vs-development-dependencies/ |
|
Uninstalling Packages Using pip 01:27
| https://realpython.com/lessons/uninstall-packages/ |
|
Alternatives to pip 01:19
| https://realpython.com/lessons/alternatives-pip/ |
|
A Beginner's Guide to pip (Quiz) 05:30
| https://realpython.com/lessons/a-beginners-guide-to-pip-quiz/ |
|
A Beginner's Guide to pip (Summary) 00:42
| https://realpython.com/lessons/what-is-pip-summary/ |
| Privacy Policy | https://realpython.com/privacy-policy/ |
Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover