2016-03-02 66 views
0

我試圖使用IMDB3來獲取一些關於電影的信息,但我無法導入包。這種其他包裝https://github.com/doganaydin/themoviedb/也會發生同樣的情況。在django視圖中導入TMDB3包

當我嘗試導入tmdb3包views.py,我得到一個ImportError: No module named 'tmdb_api'

我怎麼能導入tmdb3到我的項目?

我的django應用程序在D:/Bureau/Django/DVDDB/DVDataBase。 Python是安裝在C:\Program Files\Python 3.5\

我使用Python 3.5和Django的1.9.3在Windows 10

這裏(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

它看起來像pytmdb3不支持Python 3.您可以嘗試使用tmdbsimple來代替,這似乎支持Python 2.您的其他選項是切換到Python 2(不理想)或更新pytmdb3以支持Python 3.

具體錯誤是來自m該行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, \ 

但是,一旦更改了該行,你可能會得到其他錯誤。

+0

呃,忘了檢查Python 3的兼容性。事實上,這不是根據[這個問題](https://github.com/wagnerrp/pytmdb3/issues/18)。我會更仔細地檢查下次,謝謝:) – SoFolichon