flask-mongoengine from mongoengine.document import Document, EmbeddedDocument ImportError: cannot import name...












0















i want use flask-mongoengine develop application, but appear importError at startup application



my flask run.py






#!/usr/bin/env python
# -*- coding: utf-8 -*-

from app import app


if __name__ == '__main__':
app.run(debug=True)





my app init.py






#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Flask
import flask_mongoengine
from flask_mongoengine import MongoEngine

app = Flask(__name__)

app.config['MONGODB_SETTINGS'] = {
'db': 'datasync_datax',
'host': '192.168.100.85',
'port': 27017
}

db = MongoEngine()
db.init_app(app)





Problems encountered at startup:






Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1596, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 974, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/run.py", line 4, in <module>
from app import app
File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/app/__init__.py", line 5, in <module>
import flask_mongoengine
File "/Library/Python/2.7/site-packages/flask_mongoengine/__init__.py", line 6, in <module>
import mongoengine
File "/Library/Python/2.7/site-packages/mongoengine/__init__.py", line 3, in <module>
from mongoengine import document
File "/Library/Python/2.7/site-packages/mongoengine/document.py", line 44, in <module>
class EmbeddedDocument(six.with_metaclass(DocumentMetaclass, BaseDocument)):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py", line 566, in with_metaclass
return meta("NewBase", bases, {})
File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 151, in __new__
CachedReferenceField) = mcs._import_classes()
File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 243, in _import_classes
Document = _import_class('Document')
File "/Library/Python/2.7/site-packages/mongoengine/common.py", line 27, in _import_class
from mongoengine.fields import __all__ as fields
File "/Library/Python/2.7/site-packages/mongoengine/fields.py", line 34, in <module>
from mongoengine.document import Document, EmbeddedDocument
ImportError: cannot import name Document





my develop environment in python2.7



I don't know what's wrong.



pymongo、mongoengine、flask-mongoengine already installed










share|improve this question



























    0















    i want use flask-mongoengine develop application, but appear importError at startup application



    my flask run.py






    #!/usr/bin/env python
    # -*- coding: utf-8 -*-

    from app import app


    if __name__ == '__main__':
    app.run(debug=True)





    my app init.py






    #!/usr/bin/env python
    # -*- coding: utf-8 -*-

    from flask import Flask
    import flask_mongoengine
    from flask_mongoengine import MongoEngine

    app = Flask(__name__)

    app.config['MONGODB_SETTINGS'] = {
    'db': 'datasync_datax',
    'host': '192.168.100.85',
    'port': 27017
    }

    db = MongoEngine()
    db.init_app(app)





    Problems encountered at startup:






    Traceback (most recent call last):
    File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1596, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
    File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 974, in run
    pydev_imports.execfile(file, globals, locals) # execute the script
    File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/run.py", line 4, in <module>
    from app import app
    File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/app/__init__.py", line 5, in <module>
    import flask_mongoengine
    File "/Library/Python/2.7/site-packages/flask_mongoengine/__init__.py", line 6, in <module>
    import mongoengine
    File "/Library/Python/2.7/site-packages/mongoengine/__init__.py", line 3, in <module>
    from mongoengine import document
    File "/Library/Python/2.7/site-packages/mongoengine/document.py", line 44, in <module>
    class EmbeddedDocument(six.with_metaclass(DocumentMetaclass, BaseDocument)):
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py", line 566, in with_metaclass
    return meta("NewBase", bases, {})
    File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 151, in __new__
    CachedReferenceField) = mcs._import_classes()
    File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 243, in _import_classes
    Document = _import_class('Document')
    File "/Library/Python/2.7/site-packages/mongoengine/common.py", line 27, in _import_class
    from mongoengine.fields import __all__ as fields
    File "/Library/Python/2.7/site-packages/mongoengine/fields.py", line 34, in <module>
    from mongoengine.document import Document, EmbeddedDocument
    ImportError: cannot import name Document





    my develop environment in python2.7



    I don't know what's wrong.



    pymongo、mongoengine、flask-mongoengine already installed










    share|improve this question

























      0












      0








      0








      i want use flask-mongoengine develop application, but appear importError at startup application



      my flask run.py






      #!/usr/bin/env python
      # -*- coding: utf-8 -*-

      from app import app


      if __name__ == '__main__':
      app.run(debug=True)





      my app init.py






      #!/usr/bin/env python
      # -*- coding: utf-8 -*-

      from flask import Flask
      import flask_mongoengine
      from flask_mongoengine import MongoEngine

      app = Flask(__name__)

      app.config['MONGODB_SETTINGS'] = {
      'db': 'datasync_datax',
      'host': '192.168.100.85',
      'port': 27017
      }

      db = MongoEngine()
      db.init_app(app)





      Problems encountered at startup:






      Traceback (most recent call last):
      File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1596, in <module>
      globals = debugger.run(setup['file'], None, None, is_module)
      File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 974, in run
      pydev_imports.execfile(file, globals, locals) # execute the script
      File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/run.py", line 4, in <module>
      from app import app
      File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/app/__init__.py", line 5, in <module>
      import flask_mongoengine
      File "/Library/Python/2.7/site-packages/flask_mongoengine/__init__.py", line 6, in <module>
      import mongoengine
      File "/Library/Python/2.7/site-packages/mongoengine/__init__.py", line 3, in <module>
      from mongoengine import document
      File "/Library/Python/2.7/site-packages/mongoengine/document.py", line 44, in <module>
      class EmbeddedDocument(six.with_metaclass(DocumentMetaclass, BaseDocument)):
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py", line 566, in with_metaclass
      return meta("NewBase", bases, {})
      File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 151, in __new__
      CachedReferenceField) = mcs._import_classes()
      File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 243, in _import_classes
      Document = _import_class('Document')
      File "/Library/Python/2.7/site-packages/mongoengine/common.py", line 27, in _import_class
      from mongoengine.fields import __all__ as fields
      File "/Library/Python/2.7/site-packages/mongoengine/fields.py", line 34, in <module>
      from mongoengine.document import Document, EmbeddedDocument
      ImportError: cannot import name Document





      my develop environment in python2.7



      I don't know what's wrong.



      pymongo、mongoengine、flask-mongoengine already installed










      share|improve this question














      i want use flask-mongoengine develop application, but appear importError at startup application



      my flask run.py






      #!/usr/bin/env python
      # -*- coding: utf-8 -*-

      from app import app


      if __name__ == '__main__':
      app.run(debug=True)





      my app init.py






      #!/usr/bin/env python
      # -*- coding: utf-8 -*-

      from flask import Flask
      import flask_mongoengine
      from flask_mongoengine import MongoEngine

      app = Flask(__name__)

      app.config['MONGODB_SETTINGS'] = {
      'db': 'datasync_datax',
      'host': '192.168.100.85',
      'port': 27017
      }

      db = MongoEngine()
      db.init_app(app)





      Problems encountered at startup:






      Traceback (most recent call last):
      File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1596, in <module>
      globals = debugger.run(setup['file'], None, None, is_module)
      File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 974, in run
      pydev_imports.execfile(file, globals, locals) # execute the script
      File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/run.py", line 4, in <module>
      from app import app
      File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/app/__init__.py", line 5, in <module>
      import flask_mongoengine
      File "/Library/Python/2.7/site-packages/flask_mongoengine/__init__.py", line 6, in <module>
      import mongoengine
      File "/Library/Python/2.7/site-packages/mongoengine/__init__.py", line 3, in <module>
      from mongoengine import document
      File "/Library/Python/2.7/site-packages/mongoengine/document.py", line 44, in <module>
      class EmbeddedDocument(six.with_metaclass(DocumentMetaclass, BaseDocument)):
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py", line 566, in with_metaclass
      return meta("NewBase", bases, {})
      File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 151, in __new__
      CachedReferenceField) = mcs._import_classes()
      File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 243, in _import_classes
      Document = _import_class('Document')
      File "/Library/Python/2.7/site-packages/mongoengine/common.py", line 27, in _import_class
      from mongoengine.fields import __all__ as fields
      File "/Library/Python/2.7/site-packages/mongoengine/fields.py", line 34, in <module>
      from mongoengine.document import Document, EmbeddedDocument
      ImportError: cannot import name Document





      my develop environment in python2.7



      I don't know what's wrong.



      pymongo、mongoengine、flask-mongoengine already installed






      #!/usr/bin/env python
      # -*- coding: utf-8 -*-

      from app import app


      if __name__ == '__main__':
      app.run(debug=True)





      #!/usr/bin/env python
      # -*- coding: utf-8 -*-

      from app import app


      if __name__ == '__main__':
      app.run(debug=True)





      #!/usr/bin/env python
      # -*- coding: utf-8 -*-

      from flask import Flask
      import flask_mongoengine
      from flask_mongoengine import MongoEngine

      app = Flask(__name__)

      app.config['MONGODB_SETTINGS'] = {
      'db': 'datasync_datax',
      'host': '192.168.100.85',
      'port': 27017
      }

      db = MongoEngine()
      db.init_app(app)





      #!/usr/bin/env python
      # -*- coding: utf-8 -*-

      from flask import Flask
      import flask_mongoengine
      from flask_mongoengine import MongoEngine

      app = Flask(__name__)

      app.config['MONGODB_SETTINGS'] = {
      'db': 'datasync_datax',
      'host': '192.168.100.85',
      'port': 27017
      }

      db = MongoEngine()
      db.init_app(app)





      Traceback (most recent call last):
      File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1596, in <module>
      globals = debugger.run(setup['file'], None, None, is_module)
      File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 974, in run
      pydev_imports.execfile(file, globals, locals) # execute the script
      File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/run.py", line 4, in <module>
      from app import app
      File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/app/__init__.py", line 5, in <module>
      import flask_mongoengine
      File "/Library/Python/2.7/site-packages/flask_mongoengine/__init__.py", line 6, in <module>
      import mongoengine
      File "/Library/Python/2.7/site-packages/mongoengine/__init__.py", line 3, in <module>
      from mongoengine import document
      File "/Library/Python/2.7/site-packages/mongoengine/document.py", line 44, in <module>
      class EmbeddedDocument(six.with_metaclass(DocumentMetaclass, BaseDocument)):
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py", line 566, in with_metaclass
      return meta("NewBase", bases, {})
      File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 151, in __new__
      CachedReferenceField) = mcs._import_classes()
      File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 243, in _import_classes
      Document = _import_class('Document')
      File "/Library/Python/2.7/site-packages/mongoengine/common.py", line 27, in _import_class
      from mongoengine.fields import __all__ as fields
      File "/Library/Python/2.7/site-packages/mongoengine/fields.py", line 34, in <module>
      from mongoengine.document import Document, EmbeddedDocument
      ImportError: cannot import name Document





      Traceback (most recent call last):
      File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1596, in <module>
      globals = debugger.run(setup['file'], None, None, is_module)
      File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 974, in run
      pydev_imports.execfile(file, globals, locals) # execute the script
      File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/run.py", line 4, in <module>
      from app import app
      File "/Users/huan/sources/python-sources/bt-ware-datasync-datax/app/__init__.py", line 5, in <module>
      import flask_mongoengine
      File "/Library/Python/2.7/site-packages/flask_mongoengine/__init__.py", line 6, in <module>
      import mongoengine
      File "/Library/Python/2.7/site-packages/mongoengine/__init__.py", line 3, in <module>
      from mongoengine import document
      File "/Library/Python/2.7/site-packages/mongoengine/document.py", line 44, in <module>
      class EmbeddedDocument(six.with_metaclass(DocumentMetaclass, BaseDocument)):
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py", line 566, in with_metaclass
      return meta("NewBase", bases, {})
      File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 151, in __new__
      CachedReferenceField) = mcs._import_classes()
      File "/Library/Python/2.7/site-packages/mongoengine/base/metaclasses.py", line 243, in _import_classes
      Document = _import_class('Document')
      File "/Library/Python/2.7/site-packages/mongoengine/common.py", line 27, in _import_class
      from mongoengine.fields import __all__ as fields
      File "/Library/Python/2.7/site-packages/mongoengine/fields.py", line 34, in <module>
      from mongoengine.document import Document, EmbeddedDocument
      ImportError: cannot import name Document






      importerror flask-mongoengine






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 '18 at 8:34









      luoceluoce

      1




      1
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The problem has been solved.



          I updated my library flask-mongoengine!






          sudo pip install --upgrade flask-mongoengine








          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426769%2fflask-mongoengine-from-mongoengine-document-import-document-embeddeddocument-im%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The problem has been solved.



            I updated my library flask-mongoengine!






            sudo pip install --upgrade flask-mongoengine








            share|improve this answer




























              0














              The problem has been solved.



              I updated my library flask-mongoengine!






              sudo pip install --upgrade flask-mongoengine








              share|improve this answer


























                0












                0








                0







                The problem has been solved.



                I updated my library flask-mongoengine!






                sudo pip install --upgrade flask-mongoengine








                share|improve this answer













                The problem has been solved.



                I updated my library flask-mongoengine!






                sudo pip install --upgrade flask-mongoengine








                sudo pip install --upgrade flask-mongoengine





                sudo pip install --upgrade flask-mongoengine






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 23 '18 at 2:25









                luoceluoce

                1




                1
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426769%2fflask-mongoengine-from-mongoengine-document-import-document-embeddeddocument-im%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Costa Masnaga

                    Fotorealismo

                    Sidney Franklin