2015-06-03 90 views
0

我的同事在Ubuntu上啓動了一個django項目。我想在OS X Yosemite上運行同一個項目。我們都使用python3.4和以下軟件包:無法在從ubuntu導入的mac上運行django項目

  • 的Django(1.8.2)
  • 枕頭(2.8.1)
  • PIP(7.0.3)
  • setuptools的(17.0)
  • 輪(0.24.0)

而且我們都在虛擬環境中運行項目。

當我克隆的項目,我用

蟒蛇manage.py執行syncdb

而且我得到了以下結果:

Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line 
    utility.execute() 
    File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/core/management/__init__.py", line 312, in execute 
    django.setup() 
    File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/__init__.py", line 18, in setup 
    apps.populate(settings.INSTALLED_APPS) 
    File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/apps/registry.py", line 115, in populate 
    app_config.ready() 
    File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/contrib/admin/apps.py", line 22, in ready 
    self.module.autodiscover() 
    File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/contrib/admin/__init__.py", line 24, in autodiscover 
    autodiscover_modules('admin', register_to=site) 
    File "/Users/user/Desktop/projectName/lib/python3.4/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules 
    import_module('%s.%s' % (app_config.name, module_to_search)) 
    File "/Users/user/Desktop/projectName/lib/python3.4/importlib/__init__.py", line 109, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
    File "<frozen importlib._bootstrap>", line 2254, in _gcd_import 
    File "<frozen importlib._bootstrap>", line 2237, in _find_and_load 
    File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked 
    File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked 
    File "<frozen importlib._bootstrap>", line 1129, in _exec 
    File "<frozen importlib._bootstrap>", line 1471, in exec_module 
    File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed 
    File "/Users/user/Desktop/projectName/projectName/main/admin.py", line 3, in <module> 
    from models import ContactLink, ContactPost, Personnel, WorkCategory, Service, Skill, Work, Customer 
ImportError: No module named 'models' 

我不知道爲什麼出現這種情況和使用本網站和其他網站中描述的幾種方法。 發生了什麼,爲什麼?

回答

2

這個應該也在你的Ubuntu安裝中拋出一個錯誤。

您需要更改的projectName/main/admin.pyline 3到:

from .models import ContactLink, ContactPost, Personnel, \ 
    WorkCategory, Service, Skill, Work, Customer 

注意添加點.from .models部分。導入應該是相對的(假設所有這些模型都存在於相同的main應用程序中)。

+0

謝謝你的回答。 – aakpro