使用django_cups导入错误

时间:2013-06-10 10:29:46

标签: django

我在我的项目中使用django_cups,我在模型行4中遇到导入错误。Here is the models.py file

python ./manage.py runserver

...
File "/home/lex/myapp/django_cups/models.py", line 4, in <module>
import cups
ImportError: No module named cups

我安装了django_cups,因为当我在python shell中import cups时它没有抱怨。

lex@lex-pc:~/django/mykapp$ python
Python 2.7.4 (default, Apr 19 2013, 18:32:33) 
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cups
>>> 
>>> 

但是当我在Django的InteractiveConsole中这样做时,它抱怨......

(env)lex@lex-pc:~/django/myapp$ python ./manage.py shell
Python 2.7.4 (default, Apr 19 2013, 18:32:33) 
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import cups
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: No module named cups
>>> 

这可能是什么问题?

1 个答案:

答案 0 :(得分:1)

默认情况下,虚拟环境不包含系统软件包。要同时使用系统和本地程序包,请在创建环境时使用virtualenv --system-site-packages