Makemessages在设置上抛出ImportError

时间:2013-10-14 12:51:04

标签: python django internationalization virtualenv

我需要一些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,这可能是个问题?
我还尝试从 MyProject 子目录运行makemessages,但我得到了同样的错误。
我不明白。我搜索了遍布stackoverflow和许多网站,我甚至没有找到一个有效的解决方案。
我在Windows上使用Django 1.6,Python 3.3。


谢谢你的帮助。

此致 M. Choko

0 个答案:

没有答案