如何将模块/应用程序添加到virtualenv项目?

时间:2013-02-11 12:27:14

标签: python django

我正在尝试在我的计算机https://github.com/nathanborror/django-basic-apps

上安装nathan burrows基本应用程序
  

Django项目的简单应用程序。

     

要安装列出的任何应用,只需在您的网站上创建一个文件夹   PYTHONPATH命名为“basic”,并将您希望使用的应用程序放在其中   夹。然后添加基本。到你的项目的settings.py   文件。 (自然地替换你想要使用的应用程序。)

我已经设置了一个virtualenv项目,并将洞穴的“blog”app文件夹复制/粘贴到我的项目文件夹中。 目录结构:
MainvirtualenvFolder ----------->(Basic,Mysite,manage.py)
基本文件夹有“博客”应用程序文件夹。 Mysite文件夹有通常的django文件,如设置等。

我已经编辑了settings.py“Insalled Apps”以包含“basic.blog”。

然而,当运行manage.py(在virtualenv ofcourse下)时,我收到错误:

  

错误:没有名为basic.blog的模块

我做错了什么?

编辑 -

> ^C(mike)prince@kingdom:~/projects/mike/basicsite$ python manage.py
> syncdb Traceback (most recent call last):   File "manage.py", line 10,
> in <module>
>     execute_from_command_line(sys.argv)   File "/home/prince/projects/mike/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 443, in execute_from_command_line
>     utility.execute()   File "/home/prince/projects/mike/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 382, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)   File "/home/prince/projects/mike/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 196, in run_from_argv
>     self.execute(*args, **options.__dict__)   File "/home/prince/projects/mike/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 231, in execute
>     self.validate()   File "/home/prince/projects/mike/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 266, in validate
>     num_errors = get_validation_errors(s, app)   File "/home/prince/projects/mike/local/lib/python2.7/site-packages/django/core/management/validation.py",
> line 30, in get_validation_errors
>     for (app_name, error) in get_app_errors().items():   File "/home/prince/projects/mike/local/lib/python2.7/site-packages/django/db/models/loading.py",
> line 158, in get_app_errors
>     self._populate()   File "/home/prince/projects/mike/local/lib/python2.7/site-packages/django/db/models/loading.py",
> line 67, in _populate
>     self.load_app(app_name)   File "/home/prince/projects/mike/local/lib/python2.7/site-packages/django/db/models/loading.py",
> line 88, in load_app
>     models = import_module('.models', app_name)   File "/home/prince/projects/mike/local/lib/python2.7/site-packages/django/utils/importlib.py",
> line 35, in import_module
>     __import__(name)   File "/home/prince/projects/mike/basicsite/basic/blog/models.py", line 10,
> in <module>
>     import tagging ImportError: No module named tagging

1 个答案:

答案 0 :(得分:1)

__init__.py放在基本文件夹中。

如果该应用内部再次丢失模块:

  1. 搜索该模块
  2. pip install
  3. 将该模块放入INSTALLED_APPS settings.py
  4. 中的{{1}}