sudo add-apt-repository ppa:jd-team/jdownloader sudo apt-get update sudo apt-get install jdownloader
Category Archives: GNU/Linux
“AttributeError: ‘module’ object has no attribute ‘MongoClient’” error with Pymongo in Ubuntu 12.04
I’m currently doing the M101P: MongoDB for Developers online course.
I had this error while running one of the homeworks with pymongo in Ubuntu 12.04:
AttributeError: 'module' object has no attribute 'MongoClient'
I had previously installed pymongo with apt-get
like this:
sudo apt-get install python-pymongo
It looks like the package is outdated or broken so I had to remove the pymongo I had installed before and reinstall it using PiP:
sudo apt-get purge python-pymongo sudo apt-get install python-pip sudo pip install pymongo
Ref: http://stackoverflow.com/questions/17624416/cant-import-mongoclient
Using screen to leave processes running in a terminal
If you are using an SSH connection and run a command that takes very long to process you can use nohup
to prevent that process to be terminated when you logut from the SSH session:
nohup command > /dev/null 2>&1 &
But using this method detaches the process from stdio, stdout and stderr (unless you redirect them somewhere, as previous example redirected them to /dev/null
). If you want to be able to reattach to that process later on screen
is the right tool.
Firt install screen
:
sudo apt-get install screen
Then run a bash shell using screen
:
screen bash
A new shell wil be openen and the you can run anything you want. Lets supose you start converting a huge video to another codec. Once the process has started you have to press CTRL+A and then D to detach from that shell. Now you’ll be back to the original shell but the video process will still be running.
If you have only one screen
process running you can reattach to it by just running this:
screen -r
If you can have multiple screen
processes at the same time you have to specify to which of them you want to attach. Using this command will tell you the names and some more info about all current screens:
screen -list
Then you can attach to them using that name:
screen -r name
If you want to terminate a screen
process just attach to it and press CTRL+D.
Source: http://raspi.tv/2012/using-screen-with-raspberry-pi-to-avoid-leaving-ssh-sessions-open
Fix locale problems in Raspbian
If you get errros like this while running commands on your Raspbian:
perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_TIME = "es_ES.utf-8", LC_MONETARY = "es_ES.utf-8", LC_CTYPE = "es_ES.utf-8", LC_COLLATE = "es_ES.utf-8", LC_MESSAGES = "es_ES.utf-8", LC_NUMERIC = "es_ES.utf-8", LANG = "C" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C").
Or those:
locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory /usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory /usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory /usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
You may have to edit /etc/default/locale
and add the default locales:
LANG=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LANGUAGE=en_GB.UTF-8
MongoDB: Recover Data after an Unexpected Shutdown in Ubuntu
If you try to run mongod
but it fails to start and have this error in the log file (/var/log/mongodb/mongodb.log
) you’ll have to repair your db.
************** Unclean shutdown detected. Please visit http://dochub.mongodb.org/core/repair for recovery instructions. ************* Thu Dec 5 14:42:47.209 [initandlisten] exception in initAndListen: 12596 old lock file, terminating Thu Dec 5 14:42:47.209 dbexit: Thu Dec 5 14:42:47.209 [initandlisten] shutdown: going to close listening sockets... Thu Dec 5 14:42:47.209 [initandlisten] shutdown: going to flush diaglog... Thu Dec 5 14:42:47.209 [initandlisten] shutdown: going to close sockets... Thu Dec 5 14:42:47.209 [initandlisten] shutdown: waiting for fs preallocator... Thu Dec 5 14:42:47.209 [initandlisten] shutdown: closing all files... Thu Dec 5 14:42:47.209 [initandlisten] closeAllFiles() finished Thu Dec 5 14:42:47.209 dbexit: really exiting now
Note: MongoDBs data files are usually located at /data/db
but in my Ubuntu installation they where in /var/lib/mongodb
.
Repair preserving data:
sudo mkdir /var/lib/mongodb0 sudo mongod --dbpath /var/lib/mongodb --repair --repairpath /var/lib/mongodb0 sudo mongod --dbpath /var/lib/mongodb0
Now that the server is up with a repaired version (/var/lib/mongodb0
) of your original data (from /var/lib/mongodb
) use mongo client to verify that everything is OK. In that case replace /var/lib/mongodb
with /var/lib/mongodb0
.
sudo rm -rf /var/lib/mongodb sudo mv /var/lib/mongodb0 /var/lib/mongodb sudo chown -R mongodb:mongodb /var/lib/mongodb
Repair without preserving data:
sudo rm /var/lib/mongodb/mongod.lock sudo mongod --dbpath /var/lib/mongodb --repair
When this completes, the repaired data files will replace the original data files in the /var/lib/mongodb
directory.
Ref: http://docs.mongodb.org/manual/tutorial/recover-data-following-unexpected-shutdown/
- Page 1 of 7
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- >