Reputation: 580
I am using some scripts I found of Github to mine data from Twitter in Python. My machine is running on Linux Mint, fyi:
One of the scripts I'm using requires me to use MongoDB, which I don't know much about.
I successfully installed MongoDB and Pymongo through Anaconda as I like to use Anaconda as much as possible.
However, when I run my program that requires access to MongoDB, I get this error message:
localhost:27017: [Errno 111] Connection refused
The advice I see online (such as from this thread) instructs me to remove the lock on MongoDB or repair it or start it, or check the status, but I just get responses that MongoDB is not on my system, like this:
Loaded: not-found (Reason: No such file or directory)
Is there a way to run MongoDB through Anaconda and get it to work for my purposes, or do I need to install it on my system?
Upvotes: 0
Views: 1913
Reputation: 85
try to install pymongo again with this command
conda install -c anaconda pymongo
and make sure that your virtual environment is working for that use
conda activate
then try
from pymongo import MongoClient
Upvotes: 0
Reputation: 352
When I was using mongodb and pymongo for managing data collected from twitter on my machine, it's really straightforward.
Run mongodb on your machine with command
mongod
Test if you can connect mongodb with command
mongo
Code with pymongo
from pymongo import MongoClient
client = MongoClient()
records = client.twitter.posts.find({}, {"_id": 0, "message": 1, "comments.message": 1}).limit(10).limit(10)
Upvotes: 1