Closed slashharsh closed 2 years ago
How can I install modules at here even I added how to install module but at here in github how to do module installation please help me out @funbeedev
@harshmangal1108 You can ignore the executable error here on github since your file is dependent on installing modules.
I installed the requirements locally and I tried running the file pymongo_basic.py but I get the following error. What needs to be done to resolve?
MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True)
Traceback (most recent call last):
File "databases/mongodb/pymongo_basic.py", line 18, in <module>
print("Available Databases", client.list_database_names())
File "/home/user/.local/lib/python3.8/site-packages/pymongo/database.py", line 1135, in __call__
raise TypeError("'Database' object is not callable. If you meant to "
TypeError: 'Database' object is not callable. If you meant to call the 'list_database_names' method on a 'MongoClient' object it is failing because no such method exists.
Actually this is based on version of Pymongo Module we are trying with "3.5.1" but it actually works fine with "2.8" version.I am updating it in requirements.txt as well you can check by installing with "pip install pymongo==2.8". Hope that helps.
@harshmangal1108 I installed pymongo 2.8 but now im getting the below error. Is there any other setup or configuration requirements? The tutorial should contain everything needed to execute the code. Please update, thanks.
Traceback (most recent call last):
File "TeachMePythonLikeIm5/databases/mongodb/env/lib/python3.8/site-packages/pymongo/mongo_client.py", line 374, in __init__
self._ensure_connected(True)
File "TeachMePythonLikeIm5/databases/mongodb/env/lib/python3.8/site-packages/pymongo/mongo_client.py", line 939, in _ensure_connected
self.__ensure_member()
File "TeachMePythonLikeIm5/databases/mongodb/env/lib/python3.8/site-packages/pymongo/mongo_client.py", line 813, in __ensure_member
member, nodes = self.__find_node()
File "TeachMePythonLikeIm5/databases/mongodb/env/lib/python3.8/site-packages/pymongo/mongo_client.py", line 904, in __find_node
raise AutoReconnect(', '.join(errors))
pymongo.errors.AutoReconnect: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "pymongo_basic.py", line 15, in <module>
client = MongoClient()
File "TeachMePythonLikeIm5/databases/mongodb/env/lib/python3.8/site-packages/pymongo/mongo_client.py", line 377, in __init__
raise ConnectionFailure(str(e))
pymongo.errors.ConnectionFailure: [Errno 111] Connection refused
I think then now you have to troubleshoot MongoDB in your system and make sure mongoDB in that system is running fine. You can check following things that might help:
mongod.lock
inside /var/lib/mongodb
sudo rm /var/lib/mongodb/mongod.lock
systemctl restart mongod.service
Is there anything else? If not then please do merge this one @funbeedev
Is there anything else? If not then please do merge this one @funbeedev
@harshmangal1108 Apologies, should have got back to you sooner on this! I'm still not able to run either of the python files.
You mentioned I need to troubleshoot mongodb on my system. I assume this means I need some extra applications installed on my system other than the ones listed in the README and requirements.txt? If so could you please list out all requirements needed to run the python tutorials. Assume the machine is clean and the user doesn't know where to start.
I'm not familiar at all with mongodb so I'm using your tutorial to learn it myself! I've now installed mongodb on my PC using sudo apt-get install mongodb
as I didn't realise initially it was a service that needed to run on the PC. I've also run the commands you listed including trying various other commands. mongodb appears to be running on my PC now but I still get the following error when running pymongo_basic.py:
MongoClient('localhost', 27017)
Traceback (most recent call last):
File "pymongo_basic.py", line 18, in <module>
print("Available Databases", client.list_database_names())
File "/home/user/.local/lib/python3.8/site-packages/pymongo/database.py", line 1047, in __call__
raise TypeError("'Database' object is not callable. If you meant to "
TypeError: 'Database' object is not callable. If you meant to call the 'list_database_names' method on a 'MongoClient' object it is failing because no such method exists.
I can spend a bit more time trying to get the file to run but I want to ask you first in case there's something obvious I'm missing :)
Tutorials should work out of the box or detail all dependencies needed so that someone new to the topic can get it running. That's why I haven't merged it yet.
Would appreciate if you could update the docs with any additional requirements needed to run the python files. Also some basic explanation into what mongodb is used for would be good :)
Thanks!
@harshmangal1108 Any chance you could still update this PR? 😅
Yeah sure! will check this once again.
Please fill in this pull request template before submitting
1. This pull request resolves #55
2. Description
Created a directory databases with sub directory mongodb for tutorials on "MongoDB database using Python3". There exists 2 files for basics knowledge of how "Pymongo" module is used to work with MongoDB using Python3.
3. Fill in checklist by marking [x]