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

  • Home
  • SEARCH
  • 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 8309627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:10:57+00:00 2026-06-08T19:10:57+00:00

I had a directory structure like the following for a Python project: my_project |_

  • 0

I had a directory structure like the following for a Python project:

my_project
|_ 
   ... 
   dirA
      |_ 
        __init__.py
        scriptA.py
   dirB
      |_
        __init__.py
        scriptB.py
   ...

Inside __init__.py of dirA (__init__.py of dirB is empty), I have:

import os
import glob
__all__ = [os.path.basename(f)[:-3] for f in glob.glob(os.path.dirname(os.path.abspath(__file__)) + "/*.py")]

Inside scriptB.py, I do:

from dirA import *

And the subsequent code which utilizes the imports works fine.

Then, I copied and pasted the whole project (with a different project directory name: my_project_new) in the same directory as the old one, and I start changing the code of scriptA.py in this newly duplicated directory. (Note: directory structure of my_project_new remains exactly the same as above).

After making the changes, I tried to run scriptB.py of my_project_new, and I found that it kept importing dirA from the original my_project directory, instead of the dirA in the current my_project_new directory. Why is this?

Further, I moved the original my_project folder to a different location, and tried to run scriptB.py of my_project_new again. It then failed to identify dirA altogether. What is happening now?

  • 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-08T19:10:58+00:00Added an answer on June 8, 2026 at 7:10 pm

    I would comment, but I don’t have enough reputation. Hopefully my guess is right.

    Are there __init__.pyc files? Maybe when it compiles the bytecode it stores the absolute path to the imports. Try removing the .pyc files and importing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following directory structure Project \Images +view.png control.xaml and in the control
A long time ago I had the following directory structure in my SVN repository
1)I had a set of .js files in a particular Directory structure. 2)I NEED
If I have a directory structure like so / ├── home │ └── user
I want to somehow change the git directory structure. Currently the architecture is like
So originally I had a structure like this in my video view: <% @video.comment_titles.each
I'm working with a project that is setup using the standard Maven directory structure
I would like to reorganize the directory structure on a hosted website (i.e. I
I had a clean working directory and brought in a clone from a Git
I had created a zip file (together with directory) under Windows as follow (Code

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.