Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError
#1
HI,

Im new to python im trying to run the project but showing
Error:
class vector(collections.Sequence): AttributeError: module 'collections' has no attribute 'Sequence'
import collections
import math
import os


class vector(collections.Sequence):
Kindly help
buran write May-18-2023, 04:26 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.

Attached Files

.py   base.py (Size: 13.17 KB / Downloads: 103)
Reply
#2
Where did you get this code?

collections is part of the standard library and is installed when you install Python. The standard library version of collections does not contain anything named Sequence. My guess is the author of your code is using a different module that has a the same name. It would be likely that this module would be part of a package.
Reply
#3
From python3.9 docs:
Quote:Deprecated since version 3.3, will be removed in version 3.10: Moved Collections Abstract Base Classes to the collections.abc module. For backwards compatibility, they continue to be visible in this module through Python 3.9.

you should be using collections.abc.Sequence

https://docs.python.org/3.11/library/col...ctions.abc
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020