Python Forum
Attribute of module shelve doesn't work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Attribute of module shelve doesn't work
#1
import shelve
db = shelve.open('experement')
db['name'] = 'Sam'
db['age'] = 45
db.close()
Error:
Traceback (most recent call last): File "C:/Users/Владелец/Desktop/experements/shelve.py", line 1, in <module> import shelve File "C:/Users/Владелец/Desktop/experements\shelve.py", line 2, in <module> db = shelve.open('experement') AttributeError: 'module' object has no attribute 'open'
Reply
#2
Your file is named shelve.py, so python looks for open in it. Rename your file to something different
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pylance: "... is not a known attribute of module ..." ? MvGulik 5 3,665 Jul-08-2025, 04:41 PM
Last Post: MvGulik
  PIP doesn't work YKR 1 1,528 Mar-28-2025, 02:10 PM
Last Post: snippsat
  I'm trying to install python 3.11.11 on windows 10 - it doesn't work Petonique 2 5,252 Feb-04-2025, 05:42 PM
Last Post: snippsat
  module 'openpyxl.workbook' has no attribute 'active' lsaavedra21 5 3,918 Oct-30-2024, 06:26 PM
Last Post: lsaavedra21
  Extending list doesn't work as expected mmhmjanssen 2 2,574 May-09-2024, 05:39 PM
Last Post: Pedroski55
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 4,451 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  Why doesn't calling a parent constructor work with arbitrary keyword arguments? PurposefulCoder 4 2,855 Jun-24-2023, 02:14 PM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 5,292 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  color code doesn't work harryvl 1 2,547 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  How do I get pygame module to work in Spyder? (Mac) FirstBornAlbratross 18 14,262 Dec-18-2022, 06:43 PM
Last Post: FirstBornAlbratross

Forum Jump:

User Panel Messages

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