Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPython ImportError by not using absolute_import #1356

Closed
spyder-bot opened this issue Feb 17, 2015 · 8 comments
Closed

IPython ImportError by not using absolute_import #1356

spyder-bot opened this issue Feb 17, 2015 · 8 comments

Comments

@spyder-bot
Copy link
Collaborator

From zaha...@gmail.com on 2013-04-16T13:23:06Z

Please see this SO question: http://stackoverflow.com/questions/16023318/importerror-when-using-spyder-and-ipython-in-a-virtualenv The error is due to the to modules, the one in widgets and the ipython module itself having the same name "IPython". One way to solve it is with
from future import absolute_import
In spyderlib/widgets/IPython.py

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1356

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-04-16T15:05:02Z

We don't have a file called

spyderlib/widgets/IPython.py

it's called

spyderlib/widgets/ipython.py

which shouldn't give any trouble.

So it seems you are having a problem with your installation. I guess if you eliminate "IPython.py" from your virtualenv your problem would disappear.

By the way, I reproduced the steps you mentioned in your SO post and spyder is working fine for me.

@spyder-bot
Copy link
Collaborator Author

From zaha...@gmail.com on 2013-04-16T17:08:23Z

The problem seems to be that I am working in some case-insensitive file system so both files are confused by python. It's the same as here: http://stackoverflow.com/questions/6786644/importing-python-modules-on-linux-from-an-ntfs-share

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-04-23T13:49:18Z

I'm unfamiliar with

from future import absolute_import

Jed or zahariD, do you know if it could have some unpleasant side effect?

Cc: jed.lud...@gmail.com

@spyder-bot
Copy link
Collaborator Author

From zaha...@gmail.com on 2013-04-23T17:32:46Z

All the imports would look the same and nothing would change in that particular file since you (mean to) use absolute imports everywhere. But a combination of NFTS case-insesitivness and python2 silly import rules turn the ipython import into a relative one.

Only change would be that you would have to change the syntax if you wanted to do relative imports in the module.

For example:

from spyderlib.widgets.mixins import XX

Would still work as it is so no change is needed. However if it was

from mixins import XXX

it would have to change to

from .mixins import XXX

Regards,

Zahari.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-06-29T14:46:57Z

I'm going to take a look at this one for our next release.

Summary: IPython ImportError by not using absolute_import (was: ImportError when using Spyder and Ipython in a virtualenv)
Status: Accepted
Cc: -jed.lud...@gmail.com
Labels: -Usability MS-v2.3

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-11-03T06:06:48Z

This issue was updated by revision 7fd24502e597 .

  • The problem is our widget module has the same name (insensitive-wise) as the
    real IPython one. That makes Python 2 to think it has to import
    RichIPythonWidget from our module, which is obviously wrong.
  • Thanks to zahariDgmailcom for the fix.

Status: Fixed

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-11-03T06:08:03Z

Sorry for the big delay in fixing this one. It'll be present in 2.3.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2015-02-15T16:14:34Z

Labels: -Component-IPython

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant