django模块已经导入和python egg警告

时间:2011-05-03 04:01:35

标签: python django module egg

有人可以帮我在Django中摆脱这些警告吗?

/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/_speedups.py:3: UserWarning: Module taggit was already imported from /var/www/html/matilah/taggit/__init__.py, but /usr/lib/python2.6/site-packages/django_taggit-0.9.3-py2.6.egg is being added to sys.path

Traceback (most recent call last):
 File "manage.py", line 11, in <module>
   execute_manager(settings)
 File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
   utility.execute()
 File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
   self.fetch_command(subcommand).run_from_argv(self.argv)
 File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 261, in fetch_command
   klass = load_command_class(app_name, subcommand)
 File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 67, in load_command_class
   module = import_module('%s.management.commands.%s' % (app_name, name))
 File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
   __import__(name)
 File "/usr/lib/python2.6/site-packages/haystack/__init__.py", line 154, in <module>
   handle_registrations()
 File "/usr/lib/python2.6/site-packages/haystack/__init__.py", line 151, in handle_registrations
   search_sites_conf = importlib.import_module(settings.HAYSTACK_SITECONF)
 File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
   __import__(name)
 File "/var/www/html/matilah/search_sites.py", line 2, in <module>
   haystack.autodiscover()
 File "/usr/lib/python2.6/site-packages/haystack/__init__.py", line 106, in autodiscover
   app_path = importlib.import_module(app).__path__
 File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
   __import__(name)
 File "/var/www/html/matilah/disqus/__init__.py", line 5, in <module>
   from django.utils import simplejson as json
 File "/usr/lib/python2.6/site-packages/django/utils/simplejson/__init__.py", line 111, in <module>
   import simplejson
 File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/__init__.py", line 111, in <module>

 File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/decoder.py", line 7, in <module>
 File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/scanner.py", line 10, in <module>
 File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/scanner.py", line 6, in _import_c_make_scanner
 File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/_speedups.py", line 7, in <module>
 File "/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/_speedups.py", line 4, in __bootstrap__
 File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 841, in resource_filename
   self, resource_name
 File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1310, in get_resource_filename
   self._extract_resource(manager, self._eager_to_zip(name))
 File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1332, in _extract_resource
   self.egg_name, self._parts(zip_path)
 File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 921, in get_cache_path
   self.extraction_error()
 File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 887, in extraction_error
   raise err
pkg_resources.ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg
cache:

 [Errno 13] Permission denied: '/home/interworx/.python-eggs'

The Python egg cache directory is currently set to:

 /home/interworx/.python-eggs

Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.

我不确定“模块是否已导入”错误与“无法提取PYTHON EGG”错误有关。

在我的WSGI中,我已经拥有以下行os.environ['PYTHON_EGG_CACHE'] = rel('python-eggs'),我确信这有效。否则WSGI将无法加载我的应用程序。所以我不知道该怎么做。

谢谢!

2 个答案:

答案 0 :(得分:2)

当您收到“可能是您的帐户没有对此目录的写入权限?”这样的消息时。最好快速测试一下。尝试将其更改为“/ tmp”(每个人都可写),看看事情是否开始有效。如果修复它,您可以识别更合适的目录,并确保您(或服务器)具有写入权限。

更新:您选择先解决最早的错误消息是正确的。这是一个快速实用程序,Python Module Dump,我几年前写的,用于跟踪错误包含的模块错误。您可以尝试将其插入初始化代码路径中的有趣点,并查看是否可以发现先前导入的时间。

答案 1 :(得分:0)

您的初始问题“模块已经导入”有可能确实与您的权限错误有关。您最好的选择是修复/home/interworx/.python-eggs目录中的权限/所有权设置(如上面Peter Rowell所述)。

我今天在Google Code大学看到了这个关于权限的精彩回顾。如果你有一些时间,可以毫不费力地浏览这个:http://code.google.com/edu/tools101/linux/ownership_permissions.html

请阅读上面的评论,这是我的想法:

我认为问题是.wsgi文件没有及时设置环境变量。你能发布你的.wsgi文件吗?另外,你是如何抓住包裹的?它是一个脚本吗?通过pip手动?