简体   繁体   中英

How to handle “TypeError: __init__() missing 1 required positional argument: 'path'”

I want to set up a new tinyDB object in Python 3, but TinyDB() gives me this error

Traceback (most recent call last):
  File "C:/Users/Utente/Documents/CodingStuff/AlgManager/AlgManager.py", line 4, in <module>
    db = tdb.TinyDB()
  File "C:\Users\Utente\PycharmProjects\prova\venv\lib\site-packages\tinydb\database.py", line 159, in __init__
    self._storage = storage(*args, **kwargs)
TypeError: __init__() missing 1 required positional argument: 'path'

I guess it's something about installation, because the code I wrote is really only

import tinydb as tdb

db = tdb.TinyDB()

I installed TinyDB with pip. What can I do?

No matter what python version you use TinyDB has a required parameter "path to db" when you create the instance.

Something like this:

import tinydb as tdb
db = tdb.TinyDB('path/to/db.json')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM