How does Python import modules?


If I tried to import a file on, say, a Raspberry Pi with no internet connection, would it import? I’m just wondering how exactly importing modules works.


Any modules that are bundled with your installation of Python are available offline. On your device it may not be as large as a desktop version, but you should be able to find out what modules are shipped with the version for it.

The above site has a forum which would be a good place to search for (or ask about) what modules are availabe out of the box.


Thank you for your explanation, but if some modules are available offline, why do they have to be imported instead of being already loaded?


To conserve memory. Modules are installed on the storage device inside a Python system folder and only loaded to memory when imported.


That was what I assumed, I just wanted to make sure. Thank you.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.