Aviv Cohn
Aviv Cohn

Reputation: 17243

What is installing Python modules or packages?

A Python module is just a .py source file. A Python package is simply a collection of modules.

So why do we need programs such as pip to 'install' Python modules? Why not just download the files, put them in our project's folder and import them?

What exactly does it mean to 'install' a module or a package? And what exactly does pip do?

Are things different on Windows and on Linux?

Upvotes: 11

Views: 2768

Answers (2)

Ahasanul Haque
Ahasanul Haque

Reputation: 11164

With your proposal, for each and every project you have to download the required modules as dependencies. You have to download them again and again and add them with your project which is not very suitable though some platform like node.us do it.

What pip do is to keep the modules you installed in /use/lib/python*/site-packages/ so clearly it is included in your Python's path. So, when you try to import a module or package it checks in site-package if it exists. If exists,then this code will be used with your project. If not, you will get an error.

Upvotes: 0

Maxime Chéramy
Maxime Chéramy

Reputation: 18851

So why do we need programs such as pip to 'install' Python modules? Why not just download the files, put them in our project's folder and import them?

It's just meant to facilitate the installation of softwares without having to bundle all the dependencies nor ask the user to download the files.

You can type pip install mysoftware and that will also install the required dependencies. You can also upgrade a software easily.

What exactly does it mean to 'install' a module or a package? And what exactly does pip do?

It will copy the files in a directory that is in your Python path. This way you will be able to import the package without having to copy the directory in your project.

Upvotes: 5

Related Questions