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 6321623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:10:59+00:00 2026-05-24T16:10:59+00:00

My situation is similar to one in this question… The difference is, In our

  • 0

My situation is similar to one in this question… The difference is,

In our python/django project, we have a directory called utils, which keeps basic functions…

Sometimes, we need to test some modules by running thm from console like

python myproject/some_module.py

It is all good, until python tries to import something from our utils directory…

from utils.custom_modules import some_function
ImportError: No module named custom_modules

I check my python path, and our project is on the list, each folder under the project file has __init__.py files, and when i run ipython within project directory… Everything is ok, otherwise, python imports from its own utils directory…

My collegues use the sama method without any problem, but it throws ImportError on my environment… What could be the problem that all of us was missing?

UPDATE: My project directory, and each sub-drectory have __init__.py file, and i can import other modules from my project without any problem… When i am in a diffrent folder than my procekt and i run ipython, a such import have no problem…

from someothermodule.submodule imprort blahblahblah

But, when it comes to importing utils, it fails…

UPATE 2: What caused the problem was the utils directory under django folder, which is also in the python path…

  • 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-05-24T16:11:01+00:00Added an answer on May 24, 2026 at 4:11 pm

    See the PEP on absolute and relative imports for the semantics. You probably want

    from .utils.custom_modules import some_function
    

    if you’re in a file at the top level of your package.

    Edit: This can only be done from inside a package. This is for a good reason — if you’re importing something that is part of your project, then you’re already treating it like a Python package, and you should actually make it one. You do this by adding an __init__.py file to project directory.

    Edit 2: You’ve completely changed the question. It may be possible to work around the problem, but the correct thing to do is not refer to your packed the same way as a builtin package. You either need to rename utils, or make it a subpackage of another package, so you can refer to it by a non-conflicting name (like from mydjangoapp.utils.custom_modules import some_function).

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

Sidebar

Related Questions

I have a situation very similar to the one in this question: Selective Cache
My initial situation is similar to the one in this question . Coming from
My question is similar to this one JsonConvert.DeserializeObject and "d" wrapper in WCF but
There was a question similar to this one, but w/o the answer targeted at
My question is very similar to this one: Getting an error in jQuery when
I know there is another question that exists similar to this one but I
this is a question similar to this one . But I am not good
Background: I have a situation similar to this but the solution there doesn't solve
I have a very similar situation to the person who asked: Can I serve
I don't know if you have run into a similar situation but here's a

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.