我正在尝试使用IMDB3获取有关电影的一些信息,但我无法导入该软件包。这个其他包装器https://github.com/doganaydin/themoviedb/也是如此。
当我尝试在views.py中导入tmdb3包时,我得到ImportError: No module named 'tmdb_api'
如何将tmdb3导入我的项目?
我的django应用程序位于D:/Bureau/Django/DVDDB/DVDataBase
。 Python安装在C:\Program Files\Python 3.5\
我在Windows 10上使用Python 3.5和Django 1.9.3(与pip一起安装)。
这是错误:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x000002C415E752F0>
Traceback (most recent call last):
File "C:\Program Files\Python 3.5\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Program Files\Python 3.5\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "C:\Program Files\Python 3.5\lib\site-packages\django\core\management\base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "C:\Program Files\Python 3.5\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Program Files\Python 3.5\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Program Files\Python 3.5\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Program Files\Python 3.5\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Files\Python 3.5\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Program Files\Python 3.5\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Files\Python 3.5\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Program Files\Python 3.5\lib\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 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "D:\Bureau\Django\DVDDB\DVDDB\urls.py", line 21, in <module>
url(r'^', include('DVDataBase.urls')),
File "C:\Program Files\Python 3.5\lib\site-packages\django\conf\urls\__init__.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "C:\Program Files\Python 3.5\lib\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 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "D:\Bureau\Django\DVDDB\DVDataBase\urls.py", line 3, in <module>
from . import views
File "D:\Bureau\Django\DVDDB\DVDataBase\views.py", line 6, in <module>
import tmdb3
File "C:\Program Files\Python 3.5\lib\site-packages\tmdb3\__init__.py", line 3, in <module>
from tmdb_api import Configuration, searchMovie, searchMovieWithYear, \
ImportError: No module named 'tmdb_api'
答案 0 :(得分:0)
看起来pytmdb3不支持Python 3.您可以尝试使用tmdbsimple,这似乎支持Python 2.您的其他选项是切换到Python 2(不理想)或更新pytmdb3支持Python 3。
特定错误来自tmdb3\__init__.py
from tmdb_api import Configuration, searchMovie, searchMovieWithYear, \
对于Python 3,这应该是
from tmdb.tmdb_api import Configuration, searchMovie, searchMovieWithYear, \
或
from .tmdb_api import Configuration, searchMovie, searchMovieWithYear, \
但是,一旦更改该行,您可能会收到其他错误。