出错
ModuleNotFoundError: No module named ‘haystack’
找到settings,将
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_cn_backend.WhooshEngine',
'PATH': os.path.join(BASE_DIR, 'whoosh_index'),
}
}
改为
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(BASE_DIR, 'whoosh_index'),
}
}
因为python的django框架在2.0版本以上已经不存在whoosh_cn_backend
下载django-haystack 2.8.1
https://pypi.org/project/django-haystack/#files
将安装包解压到python下的Lib目录下,进入django-haystack-2.8.1,会看到set.py,
在命令行进入set.py目录下输入pip install django-haystack
,下面表示安装成功
ImportError: cannot import name ‘six’ from ‘django.utils’
(C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\site-packages\django-3.0.4-py3.7.egg\django\utils_init_.py)
原因
django 3.x 系列删除了six.
解决办法
第一步:安装six,尽量在d:目录下(我的是:D:\program\python3\python(2)\Lib
)
第二步:
C:\Users\DELL\AppData\Local\Programs\Python\Python37\Lib\site-packages
cd #进入家目录
cd .local/lib/python3.6/site-packages
cp six.py django/utils #将six.py拷贝进django/utils/目录下Django-3.0.4-py3.7.egg\django\utils
第三步:
C:\Users\DELL\AppData\Local\Programs\Python\Python37\Lib\site-packages\haystack
# 将site-packages/haystack/inputs.py 中
from django.utils.encoding import force_text, python_2_unicode_compatible
# 改为
from django.utils.encoding import force_text
from django.utils.six import python_2_unicode_compatible
# 问题解决
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?
django.core.exceptions.improperyconfigured:加载MySQLdb模块时出错。
你安装了mysqlclient吗?
安装mysqlclient
将安装包解压到python下的Lib目录下,进入mysqlclient-1.4.6,会看到set.py,
在命令行进入set.py目录下输入pip install mysqlclient
,下面表示安装成功
from moviepy.editor import VideoFileClip ModuleNotFoundError: No module named ‘moviepy’
安装moviepy
https://pypi.org/project/moviepy/#files
将安装包解压到python下的Lib目录下,进入moviepy-1.0.2,会看到set.py,
在命令行进入set.py目录下输入pip install moviepy
,下面表示安装成功
安装numpy 1.18.2
https://pypi.org/project/numpy/#files
numpy-1.18.2
将安装包解压到python下的Lib目录下,进入numpy-1.18.2,会看到set.py,
在命令行进入set.py目录下输入pip install numpy
,下面表示安装成功
from django.contrib.staticfiles.templatetags.staticfiles import static ModuleNotFoundError: No module named ‘django.contrib.staticfiles.templatetags’
( File “D:\program\python3\Django_learning\Elearn-master\ext_apps\xadmin\util.py”, line 24, in )
util.py
与其从这里导入它:from django.contrib.staticfiles.templatetags.staticfiles import static,还需要从这里导入它:from django.templatetags.static import static
ModuleNotFoundError: No module named ‘django.contrib.formtools’
下载安装django-formtools 2.2
https://pypi.org/project/django-formtools/#files
将安装包解压到python下的Lib目录下,进入django-formtools-2.2,会看到set.py,
在命令行进入set.py目录下输入pip install django-formtools
,下面表示安装成功
ModuleNotFoundError: No module named ‘httplib2’
下载httplib2 0.17.0
https://pypi.org/project/httplib2/#files
将安装包解压到python下的Lib目录下,进入httplib2-0.17.0,会看到set.py,
在命令行进入set.py目录下输入pip install httplib2
,下面表示安装成功
ModuleNotFoundError: No module named ‘import_export’
下载django-import-export-2.0.2
https://pypi.org/project/django-import-export/#files
将安装包解压到python下的Lib目录下,进入django-import-export-2.0.2,会看到set.py,
在命令行进入set.py目录下输入pip install django-import-export
,下面表示安装成功
ModuleNotFoundError: No module named ‘captcha’
https://github.com/mbi/django-simple-captcha
将安装包解压到python下的Lib目录下,进入django-simple-captcha-master,会看到set.py,
在命令行进入set.py目录下输入pip install django-simple-captcha
,下面表示安装成功
haystack.exceptions.MissingDependency: The ‘whoosh’ backend requires the installation of ‘Whoosh’. Please refer to the documentation.
下载安装Whoosh 2.7.4
https://pypi.org/project/Whoosh/#files
将安装包解压到python下的Lib目录下,进入Whoosh-2.7.4,会看到set.py,
在命令行进入set.py目录下输入pip install Whoosh
,下面表示安装成功