Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8002193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:17:11+00:00 2026-06-04T16:17:11+00:00

Why do I have to import all sub-packages if I want to use them?

  • 0

Why do I have to import all sub-packages if I want to use them?
I’ll explain myself with an example:

In [1]: import cime

In [2]: cime.runners
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/home/miki/testit/<ipython-input-2-35e09c66121a> in <module>()
----> 1 cime.runners

AttributeError: 'module' object has no attribute 'runners'

In [3]: import cime.runners

In [4]: cime.runners
Out[4]: <module 'cime.runners' from '/home/miki/testit/venv/lib/python2.7/site-packages/cime/runners/__init__.pyc'>

As you can see it’s a regular Python package:

In [5]: cime.__file__
Out[5]: '/home/miki/testit/venv/lib/python2.7/site-packages/cime/__init__.pyc'

In [6]: ls /home/miki/testit/venv/lib/python2.7/site-packages/cime
download.py   __init__.py   log.py   runners/  run.pyc   utils.pyc
download.pyc  __init__.pyc  log.pyc  run.py    utils.py

But this does not happens with built-in modules. Why?

In [7]: import os  # instead of import os.path

In [8]: os.path
Out[8]: <module 'posixpath' from '/home/miki/testit/venv/lib/python2.7/posixpath.pyc'>

Thanks,
rubik

P.S. I’m inside a virtualenv, but I don’t know if that matters.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:17:12+00:00Added an answer on June 4, 2026 at 4:17 pm

    This is a design decision by the cime (whatever that is) developers. A package does not magically import all of its subpackages. That’s a good thing, because otherwise large packages like SciPy would take forever to import (like NLTK does).

    Some packages, like os.path, NumPy and NLTK will import submodules, but they do so explicitly. If you want this to happen in your own module, do

    # __init__.py
    import .submodule
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a row collection (DataRow[] rows). And I want to import all rows
import re def strip_tags(value): Return the given HTML with all tags stripped. return re.sub(r'<[^>]*?>',
in dirA/SConscript I have: Import('env') probeenv = env.Clone() probeenv['CXXFLAGS'] += ['-fno-rtti','-Wnon-virtual-dtor'] ... stuff that
I am new in AndEngine. I have import the andEngine.jar file in eclipse. But
I have to import data from an Excel file to database and to do
I have to import some XML data into my app. Now I open a
I have to import library which is called functions.sage . How can I do
Lets assume that we have PyV8: import PyV8 ctxt = PyV8.JSContext() and a python
I have this code: import re def doReplace(toReplace): i = 1 def chapterReplacer(_): result
I have the code: import subprocess , os ffmpeg = "C:\\ffmpeg_10_6_11.exe" inVid = "C:\\test_in.avi"

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.