2016-11-15 8 views
0

Django(1.9)を実行すると、次のエラーメッセージ "ImportError:No tastypie.api module"が表示されます。以前の投稿を検索しましたが役に立たなかった(例:here)。ImportError:tastypie.apiというモジュールがありません

私は最新のdjango-tastypie(django-tastypie-0.13.3)を使用していたと思います。以下は、私が持っているv-envの現在の設定です。

あなたの提案をお知らせください。

よろしくお願いいたします。

ジャンゴ(1.9) 枕(3.4.2) ピップ(9.0.1) setuptoolsの(28.8.0) ホイール(0.30.0a0)

(env) [email protected]:/var/www/CordeliaHanelBackend-master# python manage.py runserver 
Performing system checks... 

Unhandled exception in thread started by <function wrapper at 0x7fb98582dcf8> 
Traceback (most recent call last): 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run 
    self.check(display_num_errors=True) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check 
    include_deployment_checks=include_deployment_checks, 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks 
    new_errors = check(app_configs=app_configs) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 10, in check_url_config 
    return check_resolver(resolver) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 19, in check_resolver 
    for pattern in resolver.url_patterns: 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns 
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module 
    return import_module(self.urlconf_name) 
    File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    File "/var/www/CordeliaHanelBackend-master/CordeliaHanelBackend/urls.py", line 8, in <module> 
    from tastypie.api import Api 
ImportError: No module named tastypie.api 

INSTALLED_APPに追加した場合、私が取得スタックトレース以下。

INSTALLED_APPS = [ 

    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    # 'CordeliaHanelBackend', 
    'tastypie', 
    'StudioHanel', 
] 



(env) [email protected]:/var/www/CordeliaHanelBackend-master# python manage.py runserver 
Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line 
    utility.execute() 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 176, in fetch_command 
    commands = get_commands() 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/utils/lru_cache.py", line 100, in wrapper 
    result = user_function(*args, **kwds) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 71, in get_commands 
    for app_config in reversed(list(apps.get_app_configs())): 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs 
    self.check_apps_ready() 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready 
    raise AppRegistryNotReady("Apps aren't loaded yet.") 
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. 
(env) [email protected]:/var/www/CordeliaHanelBackend-master# 

そして、ここでのPIPフリーズです:

(env) [email protected]:/var/www/CordeliaHanelBackend-master# pip freeze 
Django==1.9 
Pillow==3.4.2 

はEDIT:ケースには、あなたがURLs.pyが設定されているものを知っているしたいと思います。

Djangoのメインurls.py

# from django.conf.urls import patterns, include, url 
from django.conf.urls import * 
from django.conf import settings 
from django.conf.urls.static import static 

from django.contrib import admin 

from tastypie.api import Api 
from StudioHanel.api import * 

admin.autodiscover() 

studioHanel_api = Api(api_name='studiohanel') 
studioHanel_api.register(MenuResource()) 
studioHanel_api.register(AboutResource()) 
studioHanel_api.register(InteriorResource()) 
studioHanel_api.register(InteriorImageResource()) 
studioHanel_api.register(CaseStudyResource()) 
studioHanel_api.register(CaseStudyBulletResource()) 
studioHanel_api.register(ProductDesignResource()) 
studioHanel_api.register(ProductDesignImageResource()) 
studioHanel_api.register(ContactResource()) 

urlpatterns = patterns('', 
    # Examples: 
    # url(r'^$', 'CordeliaHanelBackend.views.home', name='home'), 
    # url(r'^blog/', include('blog.urls')), 

    url(r'^admin/', include(admin.site.urls)), 
    url(r'^api/', include(studioHanel_api.urls)), 
    url(r'^', include('StudioHanel.urls', namespace='StudioHanel')), 
) 

Djangoのアプリケーションurls.py

from django.conf.urls import patterns, include, url 

from StudioHanel import views 

urlpatterns = patterns('', 
    url(r'^$', views.index, name='index'), 
    url(r'^contact/', views.contact, name='contact'), 
) 

更新:#インストールPIP:

のようなsudoがなくてtastypieを再インストールジャンゴー・テイストタイプ

と以下のように次のエラーにジャンプ:だから私は次のように南をインストール

(env) [email protected]:/var/www/CordeliaHanelBackend-master# python manage.py runserver 
Performing system checks... 

/var/www/CordeliaHanelBackend-master/StudioHanel/urls.py:7: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead. 
    url(r'^contact/', views.contact, name='contact'), 

/var/www/CordeliaHanelBackend-master/CordeliaHanelBackend/urls.py:31: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead. 
    url(r'^', include('StudioHanel.urls', namespace='StudioHanel')), 

System check identified some issues: 

WARNINGS: 
?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS. 

System check identified 1 issue (0 silenced). 
Unhandled exception in thread started by <function wrapper at 0x7fea16b35c08> 
Traceback (most recent call last): 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run 
    self.check_migrations() 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 163, in check_migrations 
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__ 
    self.loader = MigrationLoader(self.connection) 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 49, in __init__ 
    self.build_graph() 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 170, in build_graph 
    self.load_disk() 
    File "/var/www/CordeliaHanelBackend-master/env/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 105, in load_disk 
    migration_module = import_module("%s.%s" % (module_name, migration_name)) 
    File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    File "/var/www/CordeliaHanelBackend-master/StudioHanel/migrations/0002_auto__add_field_interior_theme.py", line 2, in <module> 
    from south.utils import datetime_utils as datetime 
ImportError: No module named south.utils 

# pip install South 
Collecting South 
Installing collected packages: South 
Successfully installed South-1.0.2 

そして今、私はそれをGoogleに必要と思い、以下のようSTH。

(env) [email protected]:/var/www/CordeliaHanelBackend-master# python manage.py runserver 
Performing system checks... 

/var/www/CordeliaHanelBackend-master/StudioHanel/urls.py:7: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead. 
    url(r'^contact/', views.contact, name='contact'), 

/var/www/CordeliaHanelBackend-master/CordeliaHanelBackend/urls.py:31: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead. 
    url(r'^', include('StudioHanel.urls', namespace='StudioHanel')), 

System check identified some issues: 

WARNINGS: 
?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS. 

System check identified 1 issue (0 silenced). 
There is no South database module 'south.db.sqlite3' for your database. Please either choose a supported database, check for SOUTH_DATABASE_ADAPTER[S] settings, or remove South from INSTALLED_APPS. 
+0

INSTALLED_APPSは私たちがピップのためにあなたのvirtualenvの –

答えて

2

あなたのケースでは注意すべきことがいくつかあります。まず、virtualenvを使用しています。だから、ライブラリのインストールが

INSTALLED_APPS = [ 
    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'tastypie', 
    'CordeliaHanelBackend', 
    'StudioHanel', 
] 
+0

良い点でピップfreeze' 'の結果を表示自分の中で考えられてオーダーが必要以上sudo

pip install django-tastypie 

せずに行われる必要がありますdjango-インストールsudoを除外するtastypie。 (私の悪い私は認めます) –

関連する問題