Theano导入问题:AttributeError:'module'对象没有属性'poll'

时间:2016-08-05 05:57:59

标签: python django import theano keras

我已经切换到新机器并试图使用我的代码(在前一个代码上工作)。 我正在使用python / django / Theano / Keras以及以下版本(当然与前一台机器对齐......):

  • 的Django == 1.9.6
  • django-cors-headers == 1.1.0
  • django-user-agents == 0.3.0
  • Keras == 1.0.3
  • python-apt === 0.9.3.5ubuntu2
  • python-dateutil == 2.5.3
  • python-debian === 0.1.21-nmu2ubuntu2
  • scipy == 0.17.1
  • Theano == 0.8.2

在其中一个导入中,我收到以下错误: (请注意,在其他情况下,我得到了缺少gof的错误......但这可能是一个不同的问题)

  • 上次导入失败行:

    AttributeError: 'module' object has no attribute 'poll'
    

任何想法? 谢谢!

  • 简短版本:

File "/home/django/django_project/textlab/mainClasses/UploadNewSetCluster2TLChosen.py", line 10, in <module> from keras.models import model_from_json File "/usr/local/lib/python2.7/dist-packages/keras/__init__.py", line 2, in <module> from . import backend File "/usr/local/lib/python2.7/dist-packages/keras/backend/__init__.py", line 51, in <module> from .theano_backend import * File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 1, in <module> import theano File "/usr/local/lib/python2.7/dist-packages/theano/__init__.py", line 42, in <module> from theano.configdefaults import config File "/usr/local/lib/python2.7/dist-packages/theano/configdefaults.py", line 1452, in <module> p_out = output_subprocess_Popen([config.cxx, '-dumpversion']) File "/usr/local/lib/python2.7/dist-packages/theano/misc/windows.py", line 78, in output_subprocess_Popen out = p.communicate() File "/usr/lib/python2.7/subprocess.py", line 799, in communicate return self._communicate(input) File "/usr/lib/python2.7/subprocess.py", line 1401, in _communicate stdout, stderr = self._communicate_with_poll(input) File "/usr/lib/python2.7/subprocess.py", line 1431, in _communicate_with_poll poller = select.poll() AttributeError: 'module' object has no attribute 'poll'

  • 完整版 [05/Aug/2016 08:22:50] ERROR [/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py:284] Internal Server Error: /dashboardeventreport Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 123, in get_response response = middleware_method(request) File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py", line 61, in process_request if self.should_redirect_with_slash(request): File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py", line 79, in should_redirect_with_slash not urlresolvers.is_valid_path(request.path_info, urlconf) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 668, in is_valid_path resolve(path, urlconf) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 534, in resolve return get_resolver(urlconf).resolve(path) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 374, in resolve for pattern in self.url_patterns: File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 417, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 410, in urlconf_module return import_module(self.urlconf_name) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/home/django/django_project/django_project/urls.py", line 17, in <module> from textlab import views File "/home/django/django_project/textlab/views.py", line 43, in <module> from mainClasses import UploadNewSetCluster2TLChosen File "/home/django/django_project/textlab/mainClasses/UploadNewSetCluster2TLChosen.py", line 10, in <module> from keras.models import model_from_json File "/usr/local/lib/python2.7/dist-packages/keras/__init__.py", line 2, in <module> from . import backend File "/usr/local/lib/python2.7/dist-packages/keras/backend/__init__.py", line 51, in <module> from .theano_backend import * File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 1, in <module> import theano File "/usr/local/lib/python2.7/dist-packages/theano/__init__.py", line 42, in <module> from theano.configdefaults import config File "/usr/local/lib/python2.7/dist-packages/theano/configdefaults.py", line 1452, in <module> p_out = output_subprocess_Popen([config.cxx, '-dumpversion']) File "/usr/local/lib/python2.7/dist-packages/theano/misc/windows.py", line 78, in output_subprocess_Popen out = p.communicate() File "/usr/lib/python2.7/subprocess.py", line 799, in communicate return self._communicate(input) File "/usr/lib/python2.7/subprocess.py", line 1401, in _communicate stdout, stderr = self._communicate_with_poll(input) File "/usr/lib/python2.7/subprocess.py", line 1431, in _communicate_with_poll poller = select.poll() AttributeError: 'module' object has no attribute 'poll'

1 个答案:

答案 0 :(得分:0)

解决! 这个问题是gunicorn版本。 gunicorn没有使用pip冻结列出 - 因此如果版本对齐,我没有。 无论如何 - 这条线解决了这个问题:

sudo pip install gunicorn==19.4.5

请注意,您可能会对.theano文件夹的权限有一些问题。 在这种情况下,只需使用:

sudo chown django:django <your django folder>

谢谢!