我是python和pycharm的初学者,我想在pycharm下创建一个Django项目,为此,我遵循了此链接中的步骤:https://medium.com/@srijan.pydev_21998/configure-pycharm-for-python-django-and-introduction-to-django-rest-framework-f9c1a7cb4ba0 但是,当我运行manage.py时,出现以下错误:
E:\first_app\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 191.6014.12\helpers\pydev\pydevconsole.py" --mode=client --port=50395
import sys; print('Python %s on %s' % (sys.version, sys.platform))
import django; print('Django %s' % django.get_version())
sys.path.extend(['E:\\first_app', 'C:\\Program Files\\JetBrains\\PyCharm 191.6014.12\\helpers\\pycharm', 'C:\\Program Files\\JetBrains\\PyCharm 191.6014.12\\helpers\\pydev'])
if 'setup' in dir(django): django.setup()
import django_manage_shell; django_manage_shell.run("E:/first_app")
PyDev console: starting.
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] on win32
Django 2.2
Traceback (most recent call last):
File "<input>", line 6, in <module>
File "E:\first_app\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "E:\first_app\venv\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "E:\first_app\venv\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\hanan\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "E:\first_app\venv\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Program Files\JetBrains\PyCharm 191.6014.12\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "E:\first_app\venv\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "E:\first_app\venv\lib\site-packages\django\db\models\base.py", line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "E:\first_app\venv\lib\site-packages\django\db\models\base.py", line 321, in add_to_class
value.contribute_to_class(cls, name)
File "E:\first_app\venv\lib\site-packages\django\db\models\options.py", line 204, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "E:\first_app\venv\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "E:\first_app\venv\lib\site-packages\django\db\utils.py", line 201, in __getitem__
backend = load_backend(db['ENGINE'])
File "E:\first_app\venv\lib\site-packages\django\db\utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Users\hanan\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "E:\first_app\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 13, in <module>
from sqlite3 import dbapi2 as Database
File "C:\Program Files\JetBrains\PyCharm 191.6014.12\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\hanan\Anaconda3\lib\sqlite3\__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "C:\Program Files\JetBrains\PyCharm 191.6014.12\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\hanan\Anaconda3\lib\sqlite3\dbapi2.py", line 27, in <module>
from _sqlite3 import *
File "C:\Program Files\JetBrains\PyCharm 191.6014.12\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: DLL load failed: The specified module was not found.
谢谢您的帮助。
答案 0 :(得分:0)
我认为这是Cyd venvs在PyCharm中的一个已知错误。您可以尝试以下解决方法。
一种解决方法可能是:
import os
print(os.environ['PATH'])
PATH
环境变量添加到您的
运行/调试配置