Skip to content

ImportError in Python 3.6 importlib #6025

Closed

Description

@pllim

I see this in Python 3.6 test suites. Is this safe to ignore or should be fixed somehow? Should we move this to astropy-helpers? I am not sure where this is coming from.

home/travis/miniconda/envs/test/lib/python3.6/importlib/_bootstrap.py:205:
ImportWarning: can't resolve package from __spec__ or __package__,
falling back on __name__ and __path__

  return f(*args, **kwds)

p.s. Instead of decreasing the number of issues, I am increasing it. Sorry, @bsipocz !

Activity

  1. bsipocz commented on Jun 26, 2017

    @bsipocz
    Member

    @pllim - do you still see this? (I'm not sure what the problem was here, but maybe the helpers update had a good side effect...)

  2. pllim commented on Jun 27, 2017

    @pllim
    MemberAuthor

    I'll check when I get the chance and let you know. 😄

  3. saimn commented on Jun 27, 2017

    @saimn
    Contributor

    I also see these warnings, so did a quick debugging:

    ❯ PYTHONWARNINGS='error::ImportWarning' python setup.py test
    running test
    running build
    running build_py
    running pre_hook from astropy._erfa.setup_package for build_py command
    running pre_hook from astropy.modeling.setup_package for build_py command
    running build_ext
    running pre_hook from astropy._erfa.setup_package for build_ext command
    running pre_hook from astropy.modeling.setup_package for build_ext command
    Traceback (most recent call last):
      File "setup.py", line 105, in <module>
        **package_info
      File "/home/simon/miniconda3/lib/python3.6/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/home/simon/miniconda3/lib/python3.6/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/home/simon/miniconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/simon/dev/astropy/astropy/tests/command.py", line 201, in run
        self._build_temp_install()
      File "/home/simon/dev/astropy/astropy/tests/command.py", line 241, in _build_temp_install
        self.run_command('build')
      File "/home/simon/miniconda3/lib/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/home/simon/miniconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/simon/miniconda3/lib/python3.6/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/home/simon/miniconda3/lib/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/home/simon/miniconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/simon/dev/astropy/astropy_helpers/astropy_helpers/setup_helpers.py", line 252, in run
        orig_run(self)
      File "/home/simon/dev/astropy/astropy_helpers/astropy_helpers/commands/build_ext.py", line 301, in run
        super(build_ext, self).run()
      File "/home/simon/miniconda3/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run
        _build_ext.build_ext.run(self)
      File "/home/simon/miniconda3/lib/python3.6/distutils/command/build_ext.py", line 339, in run
        self.build_extensions()
      File "/home/simon/miniconda3/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 192, in build_extensions
        ext.sources = self.cython_sources(ext.sources, ext)
      File "/home/simon/miniconda3/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 203, in cython_sources
        from Cython.Compiler.Main \
      File "/home/simon/miniconda3/lib/python3.6/site-packages/Cython/Compiler/Main.py", line 28, in <module>
        from .Scanning import PyrexScanner, FileSourceDescriptor
      File "Cython/Compiler/Scanning.py", line 1, in init Cython.Compiler.Scanning (/home/ilan/minonda/conda-bld/cython_1482480352936/work/Cython-0.25.2/Cython/Compiler/Scanning.c:15387)
      File "/home/simon/miniconda3/lib/python3.6/site-packages/Cython/Plex/__init__.py", line 39, in <module>
        from .Scanners import Scanner
      File "Cython/Plex/Scanners.py", line 16, in init Cython.Plex.Scanners (/home/ilan/minonda/conda-bld/cython_1482480352936/work/Cython-0.25.2/Cython/Plex/Scanners.c:7116)
    ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__

    It is a Cython issue (cython/cython#1753 , cython/cython#1720) related to a new warning in Python 3.6 (http://bugs.python.org/issue25791).
    cython/cython#1720 gives some workaround, i will try.

  4. saimn commented on Jun 27, 2017

    @saimn
    Contributor

    Hmm, adding the from __future__ import absolute_import does not work, the warning is triggered by Cython itself.

  5. pllim commented on Jun 28, 2017

    @pllim
    MemberAuthor

    Wow, good investigative work, @saimn !

  6. pllim commented on Jun 28, 2017

    @pllim
    MemberAuthor

    So, since this is caused by bug upstream, should we close this issue here?

  7. added
    Close?Tell stale bot that this issue/PR is stale
    on Jun 28, 2017
  8. bsipocz commented on Jun 29, 2017

    @bsipocz
    Member

    Hmm, some of these may come from Cython, but the ones in #6303 are definitely not as I don't have Cython installed there while I was testing the RC.

  9. bsipocz commented on Jun 29, 2017

    @bsipocz
    Member

    Maybe we can do something about these? Like a specific version of Cython that doesn't have this issue when I do the release? (still no Cython installed here though, this is with pip installed 2.0rc1).

    bsipocz@tegla2:~$ PYTHONWARNINGS='error::ImportWarning' python3.6 -c 'import astropy;astropy.test()'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/sw/lib/python3.6/site-packages/astropy/utils/decorators.py", line 874, in test
        func = make_function_with_signature(func, name=name, **wrapped_args)
      File "/sw/lib/python3.6/site-packages/astropy/tests/runner.py", line 225, in test
        return runner.run_tests(**kwargs)
      File "/sw/lib/python3.6/site-packages/astropy/tests/runner.py", line 517, in run_tests
        from ..table import Table  # pylint: disable=W0611
      File "/sw/lib/python3.6/site-packages/astropy/table/__init__.py", line 44, in <module>
        from .column import Column, MaskedColumn, StringTruncateWarning, ColumnInfo
      File "/sw/lib/python3.6/site-packages/astropy/table/column.py", line 28, in <module>
        from .np_utils import fix_column_name
      File "/sw/lib/python3.6/site-packages/astropy/table/np_utils.py", line 19, in <module>
        from . import _np_utils
      File "astropy/table/_np_utils.pyx", line 8, in init astropy.table._np_utils (astropy/table/_np_utils.c:5760)
    ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
    
  10. saimn commented on Jun 29, 2017

    @saimn
    Contributor

    I think it happens inside the C code generated by Cython (see astropy/table/_np_utils.c:5760 above), so even if you don't have Cython installed.

  11. saimn commented on Jun 29, 2017

    @saimn
    Contributor

    re @pllim :

    So, since this is caused by bug upstream, should we close this issue here?

    The workarounds didn't work for me, and it seems not so easy to fix on Cython's side, so maybe the warning could be filtered ?

  12. 5 remaining items

  13. removed
    Close?Tell stale bot that this issue/PR is stale
    on Nov 30, 2017
  14. pllim commented on Nov 30, 2017

    @pllim
    MemberAuthor

    I think this is still an issue until it is fixed upstream, so keeping this open for now.

  15. saimn commented on Nov 30, 2017

    @saimn
    Contributor

    There was a fix in Cython 0.27 but disabled since ("Reopening since the implementation in 0.27.0 is not complete and was disabled in 0.27.1" : cython/cython#1715).

  16. entaylor commented on Jan 5, 2018

    @entaylor

    This is only to bump this issue: i have just started a fresh install in the course of upgrading from 2.7 to 3.6, and am encountering this error. It seems only to throw a warning; i have not noticed any other adverse effects.

  17. bsipocz commented on Jan 5, 2018

    @bsipocz
    Member

    Yes, you can certainly ignore this warning. Ultimately this will go away seamlessly once addressed upstream (and we just keep it open in the meantime to avoid duplicate reports opened for it).

  18. embray commented on Jul 8, 2021

    @embray
    Member

    This is OBE since astropy no longer supports Python 3.6, and I can't reproduce it. There is a similar/maybe related issue at pypa/setuptools#1111 which I can see if I set -Werror::ImportWarning but the issue is already worked around upstream, and is only a problem when I explicitly convert the warning to an error.

  19. pllim commented on Jul 8, 2021

    @pllim
    MemberAuthor

    We no longer see it because we are ignoring it in pytest.

    ignore:can't resolve package from __spec__

    Does this mean we can remove this from ignore list?

  20. bsipocz commented on Jul 8, 2021

    @bsipocz
    Member

    IMO we should remove it from the ignore list, or not close but update the description here if the warning is still raised in newer versions

  21. pllim commented on Jul 8, 2021

    @pllim
    MemberAuthor

    Testing in #11928 🤞

  22. saimn commented on Jul 8, 2021

    @saimn
    Contributor
  23. bsipocz commented on Jul 8, 2021

    @bsipocz
    Member

    @saimn - Cython hasn't been pinned to a minimum version in our tox, would you think we should just do that, even though it's not necessarily a requirement in setup.cfg?

  24. saimn commented on Jul 8, 2021

    @saimn
    Contributor

    @pllim - It is pinned in pyproject.toml.

  25. bsipocz commented on Jul 8, 2021

    @bsipocz
    Member

    OK, fair enough, so we won't fail for building astropy, but could run into the issue when using a binary of other packages that might have been built with older versions?

  26. saimn commented on Jul 8, 2021

    @saimn
    Contributor

    Sorry I thought it was pllim above 😁
    Yes I guess this could happen, but the cython releases is old enough now that we should be safe.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions