rjurney / Agile_Data_Code_2

Code for Agile Data Science 2.0, O'Reilly 2017, Second Edition
http://bit.ly/agile_data_science
MIT License
456 stars 306 forks source link

Vagrant VM Debian-supplied MongoDB too Old for Anaconda PyMongo #87

Closed pjhinton closed 5 years ago

pjhinton commented 5 years ago

Checking the version of MongoDB on the virtual machine:

vagrant@precise64:~/Agile_Data_Code_2$ dpkg -l mongodb
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                       Version                    Description
+++-==========================-==========================-====================================================================
ii  mongodb                    1:2.0.4-1ubuntu2.1         object/document-oriented database (metapackage)

Running the script test_pymongo.py fails with the following error message:

vagrant@precise64:~/Agile_Data_Code_2$ python ch02/test_pymongo.py 
Traceback (most recent call last):
  File "ch02/test_pymongo.py", line 4, in <module>
    list(db.executives.find({"name": "Russell Jurney"}))
  File "/home/vagrant/anaconda/lib/python3.5/site-packages/pymongo/cursor.py", line 1189, in next
    if len(self.__data) or self._refresh():
  File "/home/vagrant/anaconda/lib/python3.5/site-packages/pymongo/cursor.py", line 1104, in _refresh
    self.__send_message(q)
  File "/home/vagrant/anaconda/lib/python3.5/site-packages/pymongo/cursor.py", line 931, in __send_message
    operation, exhaust=self.__exhaust, address=self.__address)
  File "/home/vagrant/anaconda/lib/python3.5/site-packages/pymongo/mongo_client.py", line 1129, in _send_message_with_response
    server = topology.select_server(operation.read_preference)
  File "/home/vagrant/anaconda/lib/python3.5/site-packages/pymongo/topology.py", line 224, in select_server
    address))
  File "/home/vagrant/anaconda/lib/python3.5/site-packages/pymongo/topology.py", line 183, in select_servers
    selector, server_timeout, address)
  File "/home/vagrant/anaconda/lib/python3.5/site-packages/pymongo/topology.py", line 214, in _select_servers_loop
    self._description.check_compatible()
  File "/home/vagrant/anaconda/lib/python3.5/site-packages/pymongo/topology_description.py", line 121, in check_compatible
    raise ConfigurationError(self._incompatible_err)
pymongo.errors.ConfigurationError: Server at localhost:27017 reports wire version 0, but this version of PyMongo requires at least 2 (MongoDB 2.6).

The Anaconda distribution is providing pymongo 3.7.2:

vagrant@precise64:~/Agile_Data_Code_2$ pip list | grep pymongo
pymongo            3.7.2
pjhinton commented 5 years ago

Currently exploring how compatible the code installed by bootstrap.sh is with the latest Ubuntu LTS release box. To get the install to run to completion, you have to change the box name to 'ubuntu/bionic64' and remove python_software_properties from the first list of packages installed by apt-get.

https://github.com/pjhinton/Agile_Data_Code_2/commit/c345580194b1162ae61a5454451ed534b43f7e5d

The code in ch02/test_pymongo.py runs successfully after updating.

rjurney commented 5 years ago

Resolved by pull #95.