1

我需要一些有关 Django/Python 应用程序的帮助。
我尝试了很多天运行django-admin的“makemessages”命令但没有成功......

一些解释:
我的项目目录树:

MyProject
   MyProject
      locale
      settings.py
      wsgi.py
      ...
   App1
      models.py
      views.py
      ...

当我尝试跑步时

django-admin.py makemessages --all

我收到了这个错误:

(env33) PS C:\DEV\myproject> python ..\env33\Scripts\django-admin.py makemessages --all -v 3
Traceback (most recent call last):
  File "C:\DEV\env33\lib\site-packages\django\conf\__init__.py", line 132, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "C:\DEV\env33\lib\site-packages\django\utils\importlib.py", line 35, in import_module
    __import__(name)
ImportError: No module named 'myproject'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "..\env33\Scripts\django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "C:\DEV\env33\lib\site-packages\django\core\management\__init__.py", line 453, in execute_from_comman
    utility.execute()
  File "C:\DEV\env33\lib\site-packages\django\core\management\__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\DEV\env33\lib\site-packages\django\core\management\__init__.py", line 263, in fetch_command
    app_name = get_commands()[subcommand]
  File "C:\DEV\env33\lib\site-packages\django\core\management\__init__.py", line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File "C:\DEV\env33\lib\site-packages\django\conf\__init__.py", line 53, in __getattr__
    self._setup(name)
  File "C:\DEV\env33\lib\site-packages\django\conf\__init__.py", line 48, in _setup
    self._wrapped = Settings(settings_module)
  File "C:\DEV\env33\lib\site-packages\django\conf\__init__.py", line 134, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'myproject.settings' (Is it on sys.path?): No module named 'myproject'

然而 :

(env33) PS C:\DEV\myproject> Get-ChildItem Env:DJANGO_SETTINGS_MODULE

Name                    Value
----                    -----
DJANGO_SETTINGS_MODULE          myproject.settings

并且“C:\dev\myproject”在“PATH”环境变量中。我尝试使用以下命令运行 Django shell:

(env33) PS C:\DEV\myproject>python .\manage.py shell
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import myproject.settings
>>> myproject.settings.DEBUG
True
>>>

一切似乎都很好,并且 runserver 也可以正常工作。如您所见,我在 virtualenv 中工作,这可能是个问题?
我也尝试makemessagesMyProject子目录运行,但我得到了同样的错误。
我不明白。我搜索了整个 stackoverflow 和许多网站,但我什至没有找到可行的解决方案。
我正在 Windows 上使用 Django 1.6、Python 3.3。


谢谢你的帮助。

问候, M. Choko

4

0 回答 0