使用pip在Windows上安装sqlite3

问题描述 投票:0回答:1

如何在Python中安装

sqlite

我尝试了

pip install pysqlite3
,但它给了我一个错误

your texterror: subprocess-exited-with-error

 × Building wheel for pysqlite3 (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-311
      creating build\lib.win-amd64-cpython-311\pysqlite3
      copying pysqlite3\dbapi2.py -> build\lib.win-amd64-cpython-311\pysqlite3
      copying pysqlite3\__init__.py -> build\lib.win-amd64-cpython-311\pysqlite3
      running build_ext
      Builds a C extension linking against libsqlite3 library
      building 'pysqlite3._sqlite3' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pysqlite3
Failed to build pysqlite3
ERROR: Could not build wheels for p
ysqlite3, which is required to install pyproject.toml-based projects
python sqlite
1个回答
0
投票

这是因为如果您使用Windows,SQLite错误或没有安装在路径中。 您可以通过运行一个尝试打开或创建 SQLite 数据库的小程序来通过 Python 检查 SQLite 是否在您的 PC 上运行。

import sqlite3

try:
    # Attempts to create a connection to an in-memory SQLite database.
    conn = sqlite3.connect(':memory:')
    print("SQLite is running on your system.")
    conn.close()
except sqlite3.Error as e:
    print(f"Error: {e}")
    print("SQLite is not working correctly on your system.")

© www.soinside.com 2019 - 2024. All rights reserved.