django-cms:ImportError:没有名为cms的模块

时间:2021-07-14 08:51:27

A while ago I worked on a local django-cms project everything worked fine but now when I run python manage.py runserver command i get an ImportError. The only thing i did was to rename the directory where my django project was in. This happens many times when i'm working on django-cms projects (Never when i built sites with django on my own). I'm using django 1.7.1 and python 2.7. Can someone tell my why this happening and how to fix that? Here my Error message:

前段时间我在一个本地django-cms项目上工作一切正常,但是现在当我运行python manage.py runserver命令时,我得到一个ImportError。我唯一要做的就是重命名我的django项目所在的目录。当我正在研究django-cms项目时,这种情况很多次发生(当我自己用django构建网站时)。我正在使用django 1.7.1和python 2.7。有人可以告诉我为什么会发生这种情况以及如何解决这个问题?这是我的错误信息:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/apps/config.py", line 87, in create
    module = import_module(entry)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named cms

2 个解决方案

#1


1  

It seems you are using virtualenv. activate virtualenv first.

看来你正在使用virtualenv。首先激活virtualenv。

source env_directory/bin/activate

or workon envname if you are using virtualenvwrapper.

或者如果你使用的是virtualenvwrapper,则使用enonname。

#2


0  

Virtualenv has an absolute Path, because i moved my Project to another location it was broken. I found out the actual Path by typing printenv then i typed virtualenv envname to change it to the actual location.

Virtualenv有一个绝对的路径,因为我将我的项目移动到另一个位置它被打破了。我通过键入printenv找到了实际的路径,然后键入virtualenv envname将其更改为实际位置。

#1


1  

It seems you are using virtualenv. activate virtualenv first.

看来你正在使用virtualenv。首先激活virtualenv。

source env_directory/bin/activate

or workon envname if you are using virtualenvwrapper.

或者如果你使用的是virtualenvwrapper,则使用enonname。

#2


0  

Virtualenv has an absolute Path, because i moved my Project to another location it was broken. I found out the actual Path by typing printenv then i typed virtualenv envname to change it to the actual location.

Virtualenv有一个绝对的路径,因为我将我的项目移动到另一个位置它被打破了。我通过键入printenv找到了实际的路径,然后键入virtualenv envname将其更改为实际位置。