在pycharm运行没问题,但是在终端cmd或Powershell就会出错,如下:
Traceback (most recent call last):File ".\manage.py", line 22, in <module>main()File ".\manage.py", line 18, in mainexecute_from_command_line(sys.argv)File "D:\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_lineutility.execute()File "D:\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 377, in executedjango.setup()File "D:\Anaconda3\lib\site-packages\django\__init__.py", line 24, in setupapps.populate(settings.INSTALLED_APPS)File "D:\Anaconda3\lib\site-packages\django\apps\registry.py", line 114, in populateapp_config.import_models()File "D:\Anaconda3\lib\site-packages\django\apps\config.py", line 211, in import_modelsself.models_module = import_module(models_module_name)File "D:\Anaconda3\lib\importlib\__init__.py", line 127, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "<frozen importlib._bootstrap>", line 1014, in _gcd_importFile "<frozen importlib._bootstrap>", line 991, in _find_and_loadFile "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 671, in _load_unlockedFile "<frozen importlib._bootstrap_external>", line 783, in exec_moduleFile "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removedFile "D:\Anaconda3\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManagerFile "D:\Anaconda3\lib\site-packages\django\contrib\auth\base_user.py", line 48, in <module>class AbstractBaseUser(models.Model):File "D:\Anaconda3\lib\site-packages\django\db\models\base.py", line 122, in __new__new_class.add_to_class('_meta', Options(meta, app_label))File "D:\Anaconda3\lib\site-packages\django\db\models\base.py", line 326, in add_to_classvalue.contribute_to_class(cls, name)File "D:\Anaconda3\lib\site-packages\django\db\models\options.py", line 206, in contribute_to_classself.db_table = truncate_name(self.db_table, connection.ops.max_name_length())File "D:\Anaconda3\lib\site-packages\django\db\__init__.py", line 28, in __getattr__return getattr(connections[DEFAULT_DB_ALIAS], item)File "D:\Anaconda3\lib\site-packages\django\db\utils.py", line 214, in __getitem__backend = load_backend(db['ENGINE'])File "D:\Anaconda3\lib\site-packages\django\db\utils.py", line 111, in load_backendreturn import_module('%s.base' % backend_name)File "D:\Anaconda3\lib\importlib\__init__.py", line 127, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "D:\Anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py", line 14, in <module>from sqlite3 import dbapi2 as DatabaseFile "D:\Anaconda3\lib\sqlite3\__init__.py", line 23, in <module>from sqlite3.dbapi2 import *File "D:\Anaconda3\lib\sqlite3\dbapi2.py", line 27, in <module>from _sqlite3 import *ImportError: DLL load failed while importing _sqlite3: 找不到指定的模块。
解决:
去SQLite官网去下载sqlite3,
/download.html
下载完之后,直接将sqlite3.dll
粘贴至anaconda的DDLs目录下即可解决。