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

Support for newer python versions (> 3.7) #15

Open
bytesnake opened this issue Oct 6, 2022 · 3 comments
Open

Support for newer python versions (> 3.7) #15

bytesnake opened this issue Oct 6, 2022 · 3 comments

Comments

@bytesnake
Copy link

Bumping the python version from 3.6 fails because of a missing import from the collections library:

ImportError                               Traceback (most recent call last)
Cell In [2], line 7
      5 from scipy import signal
      6 import IPython.display as ipd
----> 7 from audiolazy import levinson_durbin
      8 import speech_test
      9 get_ipython().run_line_magic('matplotlib', 'inline')

File /opt/conda/lib/python3.10/site-packages/audiolazy/__init__.py:67
     16 """
     17 AudioLazy package
     18 
   (...)
     61 under the terms of the GPLv3.
     62 """
     64 # Some dunders and summary docstrings initialization
     65 __modules__, __all__, __doc__ = \
     66   __import__(__name__ + "._internals", fromlist=[__name__]
---> 67             ).init_package(__path__, __name__, __doc__)
     69 # Import all modules contents to the main namespace
     70 exec(("from .{} import *\n" * len(__modules__)).format(*__modules__))

File /opt/conda/lib/python3.10/site-packages/audiolazy/_internals.py:117, in init_package(package_path, package_name, docstring)
    102 """
    103 Package initialization, to be called only by ``__init__.py``.
    104 
   (...)
    114 used by the package to import every module into the main package namespace.
    115 """
    116 module_names = get_module_names(package_path)
--> 117 modules = get_modules(package_name, module_names)
    118 dunder_all = dunder_all_concat(modules)
    119 for module in modules:

File /opt/conda/lib/python3.10/site-packages/audiolazy/_internals.py:59, in get_modules(package_name, module_names)
     57 def get_module(name):
     58   return __import__(".".join([package_name, name]), fromlist=[package_name])
---> 59 return [get_module(name) for name in module_names]

File /opt/conda/lib/python3.10/site-packages/audiolazy/_internals.py:59, in <listcomp>(.0)
     57 def get_module(name):
     58   return __import__(".".join([package_name, name]), fromlist=[package_name])
---> 59 return [get_module(name) for name in module_names]

File /opt/conda/lib/python3.10/site-packages/audiolazy/_internals.py:58, in get_modules.<locals>.get_module(name)
     57 def get_module(name):
---> 58   return __import__(".".join([package_name, name]), fromlist=[package_name])

File /opt/conda/lib/python3.10/site-packages/audiolazy/lazy_analysis.py:23
     20 from __future__ import division
     22 from math import sin, cos, pi
---> 23 from collections import deque, Sequence, Iterable
     24 from functools import wraps, reduce
     25 from itertools import chain

ImportError: cannot import name 'Sequence' from 'collections' (/opt/conda/lib/python3.10/collections/__init__.py)
@nils-werner
Copy link

The solution is simple, import collections.abc.Sequence instead. It was introduced in Python 3.5.

@Danielavillagran
Copy link

The solution is simple, import collections.abc.Sequence instead. It was introduced in Python 3.5.

Hello! Got the same problem here! Wrote ‘from collections.abc import Sequence’ but problem persists. Did I miss something?

@huappy
Copy link

huappy commented Jul 28, 2024

The solution is simple, import collections.abc.Sequence instead. It was introduced in Python 3.5.

Hello! Got the same problem here! Wrote ‘from collections.abc import Sequence’ but problem persists. Did I miss something?

Yes, you would need to update it for every file hat uses the Collections library to import sequence and any other component that got moved to Collections.abc, such as Sequence, Iterable, and Iterator. There should be a total of about 7 different files in the AudioLazy project that have the same issue. Also note, not everything that is getting imported from Collections is from Collections.abc, so you'll have to have to separate those imports. I attached an image showing you what I mean. All of the tabs at the top are all of the files that you're going to need to change.

If you change them one at a time, you can keep running the program finding the next import that you need to change from the error line.

Hope this helps!

image

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

No branches or pull requests

4 participants