为了账号安全,请及时绑定邮箱和手机立即绑定
关注
qq_悠悠li_0

unable to open database file

Ubuntu 18.04 上开了一个项目,执行python manage.py runserver,无法启动,出现了这个问题。


感觉django 入门最难的地方在于环境配置,希望老师能够更加详细的讲解环境配置

jedi@jedi-VirtualBox:/var/www/html/test/django_test$ python manage.py runserver

Watching for file changes with StatReloader

Performing system checks...


System check identified no issues (0 silenced).

Exception in thread django-main-thread:

Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/base/base.py", line 220, in ensure_connection

    self.connect()

  File "/usr/local/lib/python3.6/dist-packages/django/utils/asyncio.py", line 24, in inner

    return func(*args, **kwargs)

  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/base/base.py", line 197, in connect

    self.connection = self.get_new_connection(conn_params)

  File "/usr/local/lib/python3.6/dist-packages/django/utils/asyncio.py", line 24, in inner

    return func(*args, **kwargs)

  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/sqlite3/base.py", line 199, in get_new_connection

    conn = Database.connect(**conn_params)

sqlite3.OperationalError: unable to open database file


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner

    self.run()

  File "/usr/lib/python3.6/threading.py", line 864, in run

    self._target(*self._args, **self._kwargs)

  File "/usr/local/lib/python3.6/dist-packages/django/utils/autoreload.py", line 53, in wrapper

    fn(*args, **kwargs)

  File "/usr/local/lib/python3.6/dist-packages/django/core/management/commands/runserver.py", line 120, in inner_run

    self.check_migrations()

  File "/usr/local/lib/python3.6/dist-packages/django/core/management/base.py", line 458, in check_migrations

    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])

  File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/executor.py", line 18, in __init__

    self.loader = MigrationLoader(self.connection)

  File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/loader.py", line 49, in __init__

    self.build_graph()

  File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/loader.py", line 212, in build_graph

    self.applied_migrations = recorder.applied_migrations()

  File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/recorder.py", line 76, in applied_migrations

    if self.has_table():

  File "/usr/local/lib/python3.6/dist-packages/django/db/migrations/recorder.py", line 56, in has_table

    return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())

  File "/usr/local/lib/python3.6/dist-packages/django/utils/asyncio.py", line 24, in inner

    return func(*args, **kwargs)

  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/base/base.py", line 260, in cursor

    return self._cursor()

  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/base/base.py", line 236, in _cursor

    self.ensure_connection()

  File "/usr/local/lib/python3.6/dist-packages/django/utils/asyncio.py", line 24, in inner

    return func(*args, **kwargs)

  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/base/base.py", line 220, in ensure_connection

    self.connect()

  File "/usr/local/lib/python3.6/dist-packages/django/db/utils.py", line 90, in __exit__

    raise dj_exc_value.with_traceback(traceback) from exc_value

  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/base/base.py", line 220, in ensure_connection

    self.connect()

  File "/usr/local/lib/python3.6/dist-packages/django/utils/asyncio.py", line 24, in inner

    return func(*args, **kwargs)

  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/base/base.py", line 197, in connect

    self.connection = self.get_new_connection(conn_params)

  File "/usr/local/lib/python3.6/dist-packages/django/utils/asyncio.py", line 24, in inner

    return func(*args, **kwargs)

  File "/usr/local/lib/python3.6/dist-packages/django/db/backends/sqlite3/base.py", line 199, in get_new_connection

    conn = Database.connect(**conn_params)

django.db.utils.OperationalError: unable to open database file


2019-12-08
回复 0

加上 duso python manage.py runserver  解决😓

2019-12-08
回复 0

sudo

2019-12-08
回复 0

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信