title: PyMongo: AttributeErrors for existing attributes in class _cmessage
body: <p>I use pymongo to connect to my databases on a mongodb server. I set everything up and used a simple tutorial to start with basic things in pymongo. I ended up writting this into a python file:</p>
  
  <pre><code>from pymongo import MongoClient
  from random import randint
  
  client = MongoClient("localhost", 27017) #Class from PyMongo module
  db = client["rothe_plana"]
  
  # Initialize database settings for employers and events collections:
  employersCollect = db["employers"]
  eventsCollect = db["events"]
  
  #-----------------------------------------------------
  #Employer database managment:
  #-----------------------------------------------------
  
  #Inserts passed dictionary objects of employer profiles:
  def insertNewEmployer(new_employer_profile):
      while True:
          try:
              readyProfile = new_employer_profile.copy()
              readyProfile['employer_id'] = randint(100, 999)
              employersCollect.insert_one()
          except pymongo.errors.DuplicateKeyError:
              continue
          break
  
  def getListOfEmployerIDs():
      pass #get employer ids to identify and render template elements.
  
  # -----------------------------------------------------
  # Events database managment:
  # -----------------------------------------------------
  
  #Inserts passed dictionary objects of event data:
  def insertNewEvent(new_event_data):
      while True:
          try:
              readyEventData = new_employer_profile.copy()
              readyEventData['event_id'] = randint(10000000, 99999999)
              employersCollect.insert_one()
          except pymongo.errors.DuplicateKeyError:
              continue
          break
  </code></pre>
  
  <p>But if I run this I get an exception: </p>
  
  <pre><code> Traceback (most recent call last):
        File "C:\Program Files\JetBrains\PyCharm 2018.1.4\helpers\pydev\pydevd.py", line 1664, in &lt;module&gt;
          main()
        File "C:\Program Files\JetBrains\PyCharm 2018.1.4\helpers\pydev\pydevd.py", line 1658, in main
          globals = debugger.run(setup['file'], None, None, is_module)
        File "C:\Program Files\JetBrains\PyCharm 2018.1.4\helpers\pydev\pydevd.py", line 1068, in run
          pydev_imports.execfile(file, globals, locals)  # execute the script
        File "C:\Program Files\JetBrains\PyCharm 2018.1.4\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
          exec(compile(contents+"\n", file, 'exec'), glob, loc)
        File "C:/Users/thoma/OneDrive/Projects_For_The_Web/Fliesen Rothe/PlanA/Pyramid_PlanA/pyramid_plana/datadbhandler.py", line 1, in &lt;module&gt;
          from pymongo import MongoClient
        File "C:\Users\thoma\OneDrive\Projects_For_The_Web\Fliesen Rothe\PlanA\Pyramid_PlanA\venv\lib\site-packages\pymongo\__init__.py", line 77, in &lt;module&gt;
          from pymongo.collection import ReturnDocument
        File "C:\Users\thoma\OneDrive\Projects_For_The_Web\Fliesen Rothe\PlanA\Pyramid_PlanA\venv\lib\site-packages\pymongo\collection.py", line 29, in &lt;module&gt;
          from pymongo import (common,
        File "C:\Users\thoma\OneDrive\Projects_For_The_Web\Fliesen Rothe\PlanA\Pyramid_PlanA\venv\lib\site-packages\pymongo\message.py", line 654, in &lt;module&gt;
          _op_msg_uncompressed = _cmessage._op_msg
      AttributeError: module 'pymongo._cmessage' has no attribute '_op_msg'
  </code></pre>
  
  <p>Since I certainly did not touch the Pymongo module code, I am doing something wrong in my code above. Also the web didn't bring up any results so is there a clear explanation for this?</p>
  
  <p><strong><em>EDIT:</em></strong> I had a closer look into the files that were provided by the above error. And I can see that the attribute in the specified class actually do exist. So that is quite strange. Even if I comment the dependent line out of pymongo, there is another AtrributeError for the same class.</p>