Heroku / Django项目不在本地工作,也许是路径问题

时间:2014-04-29 02:59:56

标签: python django heroku

我在从heroku克隆的项目文件夹中。在我运行的文件夹中

$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 8, in <module>
    from django.core.servers.basehttp import AdminMediaHandler, run, WSGIServerException, get_internal_wsgi_application
  File "/Library/Python/2.7/site-packages/django/core/servers/basehttp.py", line 26, in <module>
    from django.views import static
  File "/Library/Python/2.7/site-packages/django/views/static.py", line 95, in <module>
    template_translatable = ugettext_noop(u"Index of %(directory)s")
  File "/Library/Python/2.7/site-packages/django/utils/translation/__init__.py", line 75, in gettext_noop
    return _trans.gettext_noop(message)
  File "/Library/Python/2.7/site-packages/django/utils/translation/__init__.py", line 48, in __getattr__
    if settings.USE_I18N:
  File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'pinpoint.settings' (Is it on sys.path?): No module named pinpoint.settings

得到了这个^错误。

在搜索互联网之后,有人建议我在我的路径上加上精确定位&#34;。不完全确定如何做到这一点,但我想我必须首先检查我的路径是否有。所以我跑了

$ python
Python 2.7.5 (default, Aug 25 2013, 00:04:04) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> for path in sys.path: print path
... 

/Library/Python/2.7/site-packages/pip-1.5.4-py2.7.egg
/Library/Python/2.7/site-packages/Gimbpy-1.0-py2.7.egg
/Library/Python/2.7/site-packages/requests-2.2.1-py2.7.egg
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC
/Library/Python/2.7/site-packages

在^中我没有看到项目文件夹,也没有看到嵌套在项目文件夹中的文件夹精确定位点。嗯?我从哪里开始。我试图在本地运行我的项目,以便在我提交之前进行测试。知道我能做些什么来解决这个问题吗?我对这整体都很陌生,并且添加到路径&#34;事情。

1 个答案:

答案 0 :(得分:0)

首先在第二个命令中寻找路径列表时,你必须运行“ python manage.py shell ”而不是“python”,如前者将打开特定于您的项目的python。

注意: manage.py所在的目录路径 会自动将添加到路径中。

追加路径很简单即。

import sys
sys.path.append(<new_path>)

在添加任何路径之前,我会建议您在manage.py文件中提供设置文件的正确路径。它应该与您的manage.py所在的目录相关(以便系统可以选择它)