在FreeBSD上安装SQLite和PYTHON时出现问题

vq8itlhq  于 2022-11-15  发布在  SQLite
关注(0)|答案(2)|浏览(235)

这快把我逼疯了!您能提供的任何帮助我们都将非常欢迎!
我有一个python3/sqlite应用程序(在虚拟环境中运行),它在Debian上运行得很好。我需要将其安装在FreeBSD上(在虚拟环境中运行)。我已经安装了python3和SQLite(我可以从命令行打开一个.sqlite文件)。
当我尝试运行python脚本时,我得到以下错误:

(venv) [jordan@webServer ~/crons/powerwall]$ python3 main.py
Traceback (most recent call last):
  File "/usr/home/jordan/crons/powerwall/main.py", line 78, in <module>
    run()
  File "/usr/home/jordan/crons/powerwall/main.py", line 33, in run
    database.load_db(config_mgr=config)
  File "/usr/home/jordan/crons/powerwall/database.py", line 108, in load_db
    db = PowerWallDb(cfg_mgr=config_mgr)
  File "/usr/home/jordan/crons/powerwall/database.py", line 94, in __init__
    super().__init__(cfg_mgr=cfg_mgr, section=section)
  File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/thompcoutils/db_utils.py", line 77, in __init__
    self._connect_sqlite(self.sqlite_file, check_same_thread=False)
  File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/thompcoutils/db_utils.py", line 99, in _connect_sqlite
    self._connect_uri(uri, **kwargs)
  File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/thompcoutils/db_utils.py", line 95, in _connect_uri
    self.connection = sqlobject.sqlhub.processConnection = sqlobject.connectionForURI(uri, **kwargs)
  File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/dbconnection.py", line 1105, in connectionForURI
    conn = connCls.connectionFromURI(uri)
  File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/dbconnection.py", line 154, in connectionFromURI
    return cls._connectionFromParams(*cls._parseURI(uri))
  File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/sqlite/sqliteconnection.py", line 122, in _connectionFromParams
    return cls(filename=path, **args)
  File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/sqlite/sqliteconnection.py", line 64, in __init__
    raise ImportError(
ImportError: Cannot find an SQLite driver, tried supersqlite,pysqlite2,sqlite3,sqlite
Exception ignored in: <function DBAPI.__del__ at 0x8029c1310>
Traceback (most recent call last):
  File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/dbconnection.py", line 704, in __del__
    self.close()
  File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/sqlite/sqliteconnection.py", line 217, in close
    if self._memory:
AttributeError: 'SQLiteConnection' object has no attribute '_memory'
brccelvz

brccelvz1#

您必须安装py-sqlite3,它是“SQLite3库的标准Python绑定”
从端口安装:

cd /usr/ports/databases/py-sqlite3/ && make install clean

从pkg安装:

pkg install databases/py-sqlite3
ubby3x7f

ubby3x7f2#

从根本上说,SQLite的标准Python绑定看起来像是一个独立于FreeBSD的包(可能是在所有*nix/*BSD上)。因此,一般而言,有三个组件是您需要的,分别是:Python、SQLite(这一组件实际上可能不是Python所必需的)和SQLite的标准Python绑定。我没有用过FreeBSD,但基于谷歌,你试过安装这个https://pkgs.org/download/py39-sqlite3吗?

相关问题