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 import error #696

Closed
bash-j opened this issue Feb 17, 2017 · 5 comments
Closed

IPython import error #696

bash-j opened this issue Feb 17, 2017 · 5 comments
Assignees
Labels
bug something broken
Milestone

Comments

@bash-j
Copy link

bash-j commented Feb 17, 2017

On my IIS server running django 1.10 and plotly 2.0.1, I get the same error as explained in this issue
bokeh/bokeh#5242 , which has been patched in Bokeh.

I have modified the optional_imports.py file similarly to their fix and it also fixed my issue.

Traceback (most recent call last):
  File "...\lib\site-packages\django\core\handlers\exception.py", line 39, in inner
    response = get_response(request)
  File "...\lib\site-packages\django\core\handlers\base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "...\lib\site-packages\django\core\handlers\base.py", line 172, in _get_response
    resolver_match = resolver.resolve(request.path_info)
  File "...\lib\site-packages\django\urls\resolvers.py", line 270, in resolve
    for pattern in self.url_patterns:
  File "...\lib\site-packages\django\utils\functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "...\lib\site-packages\django\urls\resolvers.py", line 313, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "...\lib\site-packages\django\utils\functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "...\lib\site-packages\django\urls\resolvers.py", line 306, in urlconf_module
    return import_module(self.urlconf_name)
  File "...\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "....\urls.py", line 23, in <module>
    from material.frontend import urls as frontend_urls
  File "...\lib\site-packages\material\frontend\urls.py", line 7, in <module>
    url(r'', include(modules.urls)),
  File "...\lib\site-packages\material\frontend\registry.py", line 48, in urls
    patterns.append(module.urls)
  File "...\lib\site-packages\material\frontend\apps.py", line 98, in urls
    return ModuleURLResolver(base_url, self.get_urls(), module=self, app_name=self.label, namespace=self.label)
  File "...\lib\site-packages\material\frontend\apps.py", line 84, in get_urls
    urls_module = import_module(urls_module_name)
  File "...\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "app\urls.py", line 5, in <module>
    from ... import views
  File "app\views.py", line 27, in <module>
    import plotly.offline as py
  File "...\lib\site-packages\plotly\__init__.py", line 31, in <module>
    from plotly import (plotly, graph_objs, grid_objs, tools, utils, session,
  File "...\lib\site-packages\plotly\plotly\__init__.py", line 10, in <module>
    from . plotly import (
  File "...\lib\site-packages\plotly\plotly\plotly.py", line 27, in <module>
    from plotly import exceptions, files, session, tools, utils
  File "...\lib\site-packages\plotly\tools.py", line 59, in <module>
    ipython_core_display = optional_imports.get_module('IPython.core.display')
  File "...\lib\site-packages\plotly\optional_imports.py", line 23, in get_module
    return import_module(name)
  File "...\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "...\lib\site-packages\IPython\__init__.py", line 48, in <module>
    from .core.application import Application
  File "...\lib\site-packages\IPython\core\application.py", line 24, in <module>
    from IPython.core import release, crashhandler
  File "...\lib\site-packages\IPython\core\crashhandler.py", line 28, in <module>
    from IPython.core import ultratb
  File "...\lib\site-packages\IPython\core\ultratb.py", line 111, in <module>
    from IPython.core import debugger
  File "...\lib\site-packages\IPython\core\debugger.py", line 36, in <module>
    from IPython.utils import coloransi, io, py3compat
  File "...\lib\site-packages\IPython\utils\io.py", line 78, in <module>
    stdin = IOStream(sys.stdin, fallback=devnull)
  File "...\lib\site-packages\IPython\utils\io.py", line 36, in __init__
    for meth in filter(clone, dir(stream)):
  File "...\lib\site-packages\IPython\utils\io.py", line 35, in clone
    return not hasattr(self, meth) and not meth.startswith('_')
  File "...\lib\site-packages\IPython\utils\io.py", line 70, in closed
    return self.stream.closed
ValueError: underlying buffer has been detached
@cldougl
Copy link
Member

cldougl commented Apr 8, 2017

@bash-j can you confirm you're still experiencing this issue in the most recent release (2.0.7)?

@bash-j
Copy link
Author

bash-j commented Apr 10, 2017

@cldougl still seeing same ValueError after upgrading to 2.0.7. Dropped the patched version of the optional_imports.py file in and all good again.


"""
Stand-alone module to provide information about whether optional deps exist.

"""
from __future__ import absolute_import

from importlib import import_module

import logging

logger = logging.getLogger(__name__)
_not_importable = set()

def get_module(name):
    """
    Return module or None. Absolute import is required.

    :param (str) name: Dot-separated module path. E.g., 'scipy.stats'.
    :raise: (ImportError) Only when exc_msg is defined.
    :return: (module|None) If import succeeds, the module will be returned.

    """
    if name not in _not_importable:
        try:
            return import_module(name)
        except ImportError:
            _not_importable.add(name)
        except Exception:
            _not_importable.add(name)
            msg = "Failed to import optional module `{}`".format(name)
            logger.exception(msg)

@chriddyp
Copy link
Member

@jonmmease jonmmease added the bug something broken label Sep 22, 2018
@jonmmease jonmmease added this to the v3.3.0 milestone Sep 22, 2018
@jonmmease
Copy link
Contributor

This change looks reasonable to me, independent of the details of ipython's interactions with IIS, so I'm fine adding this.

@jonmmease
Copy link
Contributor

Done in #1192 . I know it's been a while, but thanks for reporting and digging into the issue @bash-j!

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

No branches or pull requests

4 participants