我已转移到python3
并尝试使用django 1.11.1
创建我的网络应用程序,即最新版本。
我已经virtualenv
设置了我已安装所有要求的位置。
根据django-doc,我选择了第二个选项,即安装mysqlclient
。现在,当我尝试迁移我的基本django表时,我收到以下错误:
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/namita/environments/p3_venv/lib/python3.5/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "/home/namita/environments/p3_venv/lib/python3.5/site-packages/django/db/models/base.py", line 124, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/home/namita/environments/p3_venv/lib/python3.5/site-packages/django/db/models/base.py", line 330, in add_to_class
value.contribute_to_class(cls, name)
File "/home/namita/environments/p3_venv/lib/python3.5/site-packages/django/db/models/options.py", line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/home/namita/environments/p3_venv/lib/python3.5/site-packages/django/db/__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/home/namita/environments/p3_venv/lib/python3.5/site-packages/django/db/utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "/home/namita/environments/p3_venv/lib/python3.5/site-packages/django/db/utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/namita/environments/p3_venv/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 30, in <module> 'Did you install mysqlclient or MySQL-python?' % e django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'. Did you install mysqlclient or MySQL-python?
我错过了任何套餐吗?另外,当我尝试安装mysql-python时,它会给ImportError: No module named 'ConfigParser'
这是公平的,因为我正在使用python3。我还检查了错误来临的行点,它有类似的东西
try:
import MySQLdb as Database
except ImportError as e:
raise ImproperlyConfigured(
'Error loading MySQLdb module: %s.\n'
'Did you install mysqlclient or MySQL-python?' % e
)
这意味着它期待MySQLdb包页。在python3中是否也需要它?请帮忙。