我目前正在尝试将我的新更改部署到我的raspberry-pi(虽然virtualenv已激活),但是当我运行python manage.py migrate
时,我收到以下错误:
Applying CloudRoni.0007_auto_20180129_2007...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 97, in database_forwards
schema_editor.create_model(model)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 303, in create_model
self.execute(sql, params or None)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 120, in execute
cursor.execute(sql, params)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 80, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 63, in execute
return self.cursor.execute(sql)
File "/home/pi/CloudRoni/cloudronienv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 326, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: unable to open database file
当我尝试运行sudo python manage.py migrate
时,我会收到:
File "manage.py", line 17, in <module>
"Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
我以前运行过迁移,自部署以来已经过了一段时间,但没有任何改变,任何疑难解答帮助都很受欢迎。
编辑:包括我的virtualenv已激活
答案 0 :(得分:0)
它显示未安装Django,您可能因为未激活虚拟环境而收到错误。 转到存在虚拟环境的特定文件夹并尝试 -
source myvenv/bin/activate
替换&#39; myvenv &#39;使用您的虚拟环境名称并尝试迁移。