我正在尝试在我的django项目中使用dlib。我正在使用aws ubuntu,但是我无法使用pip dlib,因此我根据davisking指令直接编译以使用此PR https://github.com/davisking/dlib/pull/1040。所以我成功安装了编译dlib并在我的ubuntu中安装。
现在是如何在django中使用dlib。我试过“import dlib”,但是没有认出来。
这是我安装dlib和执行的最后一部分的方法。
$ python setup.py install
.....
.....
Processing dlib-19.8.99-py2.7-linux-x86_64.egg
creating /usr/local/lib/python2.7/dist-packages/dlib-19.8.99-py2.7-linux-x86_64.egg
Extracting dlib-19.8.99-py2.7-linux-x86_64.egg to /usr/local/lib/python2.7/dist-packages
Adding dlib 19.8.99 to easy-install.pth file
Installed /usr/local/lib/python2.7/dist-packages/dlib-19.8.99-py2.7-linux-x86_64.egg
Processing dependencies for dlib==19.8.99
Finished processing dependencies for dlib==19.8.99
settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
...
'mapwidgets',
'dlib',
]
但是下面出现了错误。删除它仍然无法识别“import dlib”
Traceback (most recent call last):
File "manage.py", line 23, in <module>
execute_from_command_line(sys.argv)
File "/home/deploy/somedotcom/somedotcomenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/deploy/somedotcom/somedotcomenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/home/deploy/somedotcom/somedotcomenv/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/deploy/somedotcom/somedotcomenv/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/deploy/somedotcom/somedotcomenv/lib/python3.5/site-packages/django/apps/config.py", line 94, in create
module = import_module(entry)
File "/home/deploy/somedotcom/somedotcomenv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'dlib'
如何在我的django项目中开始使用dlib,现在导入dlib的步骤是什么?
答案 0 :(得分:0)
从堆栈跟踪看来,似乎使用了Python 3.5而不是2.7,dlib是为其构建的。您需要为正确的Python版本安装dlib。