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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:52:16+00:00 2026-05-13T05:52:16+00:00

For instance, I want to make a sql alchemy plugin for another project. And

  • 0

For instance, I want to make a sql alchemy plugin for another project. And I want to name that module sqlalchemy.py. The problem with this is that it prevents me from importing sqlalchemy:

#sqlalchemy.py
import sqlalchemy 

This will make the module import itself. I’ve tried this, but it doesn’t seem to work:

import sys
#Remove the current directory from the front of sys.path
if not sys.path[0]:
    sys.path.pop(0)
import sqlalchemy

Any suggestions?

  • 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-13T05:52:17+00:00Added an answer on May 13, 2026 at 5:52 am

    Edit: as the OP has now mentioned that the issue is one of relative import being preferred to absolute, the simplest solution for the OP’s specific problem is to add at the start of the module from __future__ import absolute_import which changes that “preference”/ordering.

    The following still applies to the ticklish issue of two clashing absolute imports (which doesn’t appear to be what the OP is currently facing…):

    Once you’ve imported a module named x, that module’s recorded in sys.modules['x'] — changing sys.path as you’re doing won’t alter sys.modules. You’ll also need to alter sys.modules directly.

    E.g., consider:

    $ cat a/foo.py
    print __file__; import sys; sys.path.insert(0, "b"); del sys.modules["foo"]; import foo
    $ cat b/foo.py
    print __file__
    $ python2.5 -c'import sys; sys.path.insert(0, "a"); import foo'
    a/foo.py
    b/foo.py
    

    (running again will use and show the .pyc files instead of the .py ones of course).

    Not the cleanest approach, and of course this way the original foo module is, inevitably, not accessible from the outside any more (since its sys.modules entry has been displaced), but you could play further fragile tricks as needed (stash sys.modules["foo"] somewhere before deleting it, after you import the other foo put that module somewhere else and reinstate the original sys.modules["foo"] — etc, etc), depending on your exact needs. (Of course, avoiding the name clashes in the first place would almost invariably be simpler than waltzing all around them in this way;-).

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

Sidebar

Related Questions

I want to make functions Double -> Double an instance of the Num typeclass.
I want to make my monad transformer to be an instance of MonadError if
I want to make sure I understand a key concept of properties and instance
I don't want to make a new instance of Form1 in the class, and
I am writing an app that uses Highcharts, and in one instance I want
I want to pass an ImageIcon instance by value as we know that by
I want to set up a SQL Server 2005 database, a Reporting Services instance,
I've come across a problem with modifying XML within SQL Server that doesn't seem
I am using SQL Server 2008 express edition but I want to make my
I want to make a constructor whose instances are jquery objects, so that var

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.