Categories
Linux Posts Python Ubuntu

ImportError: No module named …

Numeric

Error:

Traceback (most recent call last):
  File "", line 1, in
ImportError: No module named Numeric

Package:

sudo apt-get install python-numeric

ImageTk

Error:

ITraceback (most recent call last):
  File "", line 1, in
ImportError: No module named ImageTk

Package:

sudo apt-get install python-imaging-tk
Categories
Blog Command Line Linux Posts Ubuntu

A More Elegant Solution to Ubuntu Wi-Fi Reconnecting Issue

Previously I was having problems with Ubuntu dropping wifi connections and failing to reconnect, to solve this I wrote a script which would kill the network-manager and then connect using iwconfig commands (here). While this works fine, it felt a little hacky, having to have a script running as sudo constantly in the background checking for a dropped connection. After a little searching I came across cron (the time based job scheduler ) and /etc/rc.local (a script which is run after all other initialization scripts have ran, allowing for scripts to be ran on startup) so from this I decided to split the old script up into connection and checking scripts which could be ran from init.d/local and cron, respectively.

Firstly my startup script in /etc/init.d/local which sets up and connects to the wireless network, open the file as sudo:

 sudo gedit /etc/rc.local

Paste in the following:

#! /bin/sh

service network-manager stop && service networking stop

iwconfig wlan0 essid NETWORKNAME
iwconfig wlan0 key WEPKEY
ifconfig wlan0 up
dhclient3 wlan0

sleep 10

if iwconfig wlan0 | grep -o "Access Point: Not-Associated"
then
	ifconfig wlan0 down
	sleep 10
	ifconfig wlan0 up

fi

exit 0

Next the script for checking the network is still connected, if not attempt to reconnect (named wirelesscheck.sh):

#!/bin/bash

if iwconfig wlan0 | grep -o "Access Point: Not-Associated"
then

	ifconfig wlan0 down
	sleep 10
	ifconfig wlan0 up
	
fi

Make sure this script is executable (from the directory of the script):

 chmod +x wirelesscheck.sh 

Note: This is setup in the sudo crontab, only because this command needs root privileges – other commands could be added to a user crontab (by removing sudo from the following.)

Now, edit (-e) the crontab for sudo:

 sudo crontab -e 

If crontab has not previously been used choose an editor (I used nano – 2) and append this line to the bottom of the file and change the frequency and directory of the script. The current settings will run it every 5 minutes (*/5) every hour, day, month and year and the file is located in “/path/to/script/wirelesscheck.sh”.

*/5 * * * * /path/to/script/wirelesscheck.sh

If you have any issues, leave a comment and I will help if I can.

Categories
Linux OpenCV Posts Ubuntu

How To: Fix “No accelerated colorspace conversion found from yuv420p to bgr24.” | OpenCV-2.2.0 & Ubuntu 10.10

[swscaler @ 0xbf2130]No accelerated colorspace conversion found from yuv420p to bgr24.

This problem is basically an issue converting YUV to RGB using ffmpeg, in order for it to work ffmpeg needs to be recompiled with x264. To get around it use the following to recompile ffmpeg and OpenCV 2.1/2.2:

  1. Follow steps 1-to-4 of FakeOutdoorsman’s guide on ubuntuforums.org – here
  2. OpenCV 2.1/2.2 Install Guide by Sebastian Montabone – here
Categories
HowTo Linux Posts Ubuntu

How To: Fix “Failed to download repository information Check your Internet connection.”

If you’re getting this error but you’re still connected to the internet this page might help. This error is sometimes caused by repository’s which are down or broken.

Failed to download repository information
Check your Internet connection.

From terminal run the following command:

 sudo apt-get update

If the output runs through a few repositorys but ends with something similar to the below (most probably with different repositorys failing) and ultimately stopping your updating process then there is a good chance you can fix it by just removing those failing sources from the software sources.

Err http://ppa.launchpad.net maverick/main Sources
404 Not Found
Err http://ppa.launchpad.net maverick/main amd64 Packages
404 Not Found
W: Failed to fetch http://ppa.launchpad.net/bugs-sehe/gparted/ubuntu/dists/maverick/main/source/Sources.gz 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/bugs-sehe/gparted/ubuntu/dists/maverick/main/binary-amd64/Packages.gz 404 Not Found
E: Some index files failed to download, they have been ignored, or old ones used instead.

Software Sources can be found under either:

Applications > Ubuntu Software Centre > Edit > Software Sources..
OR
System > Administrator > Synaptic Package Manager > Settings > Repositorys

Click the Other Software tab.

Nnow find the repositories which caused the failure on the update and uncheck them and then close the Software Centre.

Re-run the update command and hopefully everything will work!

 sudo apt-get update

Check the example below where gparted was causing the error:

Categories
HowTo Linux Posts Ubuntu

How To: Restore Default sources.list

Having gone through several upgrades and countless repository’s added to the software sources, things can begin to get really messy really quickly and often begin to screw up when updating the system if you’re not careful. You may find yourself, like I have, wanting to restore your sources.list file back to its default in order to get things working again.

In order to do this there is a pretty handy webapp available called the “Ubuntu Sources List Generator” – http://repogen.simplylinux.ch/

By moving through each section it enables you to select your country, release and then check each repository you want to add, not only does it support all the official ones for things like security and updates, it also allows for 3rd party repos such as Banshee, Chromium, Conky and VLC amongst a bunch others. Once you have what you want hit generate and it’ll create a nice, comment, new sources.list file ready for you to replace your old one with.

You may want to backup your old sources.list just in case with the following command:

 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bkup

Once you have that you can open the sources.list and simply paste the new one in from the repogen:

 sudo gedit /etc/apt/sources.list

Paste, Save and Close the file and now you should paste the generated GPG keys, found just below the generated sources.list file, into your terminal.

Everything should be back to default and allow you to once again update everything.

Categories
Linux Posts Ubuntu

How To Fix: fatal error: Python.h: No such file or directory

 (cd ./brain/psom && make)
make[1]: Entering directory `/home/ubuntu/pyrobot/brain/psom'
(cd csom_src && make _csom.so)
make[2]: Entering directory `/home/ubuntu/pyrobot/brain/psom/csom_src'
gcc -c -g -I -I/usr/include/python2.6 som_pak_wrap.c -I/usr/include/python2.6 -Isom_pak-dev
som_pak_wrap.c:125: fatal error: Python.h: No such file or directory
compilation terminated.
make[2]: *** [som_pak_wrap.o] Error 1
make[2]: Leaving directory `/home/ubuntu/pyrobot/brain/psom/csom_src'
make[1]: *** [csom_src/_csom.so] Error 2
make[1]: Leaving directory `/home/ubuntu/pyrobot/brain/psom'
make: *** [brain/psom] Error 2

To fix

 sudo apt-get install python2.6-dev
Categories
Linux Posts

Ubuntu Disconnecting from Wi-Fi and Failing to Reconnect.

I have an updated fix for this issue using a startup script to connect and a time scheduled script for checking the connection, rather than having one constantly running in the background, avalible here – http://alexsleat.co.uk/2011/01/09/a-more-elegant-solution-to-ubuntu-wi-fi-reconnecting-issue/

I’ve been having some trouble with my wifi on Ubuntu recently but I think it’s because I’m almost out of range of the access point. The problem is that once it disconnects it never seems to be able to reconnect unless wireless is disabled and re-enabled. No doubt there is another way of fixing this issue but it gives me a chance to write my first shell script.

In short the script disables network-manager (it was trying to do things auto which was screwing with things), sets up the connection and connects then checks for a string in the wireless card parameters which will only occur if it’s disconnected, if the string appears it’ll disable and re-enable the wireless device which seems to allow it to connect again. If it’s connected it’ll wait 3 minutes (180 seconds) before checking again where as if it does disconnect it’ll check again 30 seconds after it’s tired rebooting the device.

Here’s the script, be sure to try it if you’re having the same problem (you might need to change the wireless device ‘wlan1’ to yours) and comment if I’m doing something wrong or there’s another way around this, cheers.

#!/bin/bash

service network-manager stop

iwconfig wlan1 essid NETWORKNAME
iwconfig wlan1 key NETWORKKEY
ifconfig wlan1 up
dhclient3 wlan1

while true;
do

if (iwconfig wlan1) | grep -o "Access Point: Not-Associated"
then
	ifconfig wlan1 down
	echo "not connected, rebooting Wifi"
	ifconfig wlan1 up
	sleep 30
else
	echo "connected"
	sleep 180
fi

done
Categories
Android Posts Windows

Samsung Galaxy S – Samsung Kies Connection Error

Okay so I went to check if I could get the SGS Froyo update which seems to be getting rolled out across the UK a little earlier than expected. I booted my laptop into Windows 7 64-bit, loaded Kies and was prompted to update it and once it was done I tried connected my SGS via USB and putting it in to Kies mode. Here’s where the error came about, it’d just sit there “connecting” on the Kies software on my laptop but just switching between MTP Application and the home screen on my phone.

Browsing the net I found a few “fixes” which involved deleting applications on my phone such as Soundhound (which I have never had) or more extreme and formatting the internal SD card only to have everything wiped.

The problem here though is actually just the drivers for 64-bit Win7 cannot handle corrupt data or bad files which are pretty common (say an app is loading an image from the net and you close it half way through BAM, broken file.)

So in order to fix this most annoying of errors you’re going to have to find those corrupt files on your phones memory.

  1. Close Samsung Kies
  2. Connect your phone and select ‘Mass Storage’ mode
  3. Mount USB via the notification bar
  4. Remove any corrupt files from the phones SD cards
    1. You can use this FileSearcherforKiesFix.zip to locate corrupt files
    2. Once found, navigate to the directory and remove them
    3. Research until none are found.
  5. Unmount, disconnect and reconnect the phone
  6. Open Kies and select the Kies option, it should now boot connect without any issues.

Source: (Post #50)  http://android.modaco.com/content-page/311526/samsung-galaxy-s-problems/page/40/

Categories
HowTo Posts Web

HowTo: Fix “Briefly unavailable for scheduled maintenance. Check back in a minute.”

After installing an update to WordPress I received the error:

“Briefly unavailable for scheduled maintenance. Check back in a minute.”

I was unsure if this was down to my hosts servers being temporarily down, going down during the update or if WordPress had simply failed to update whatever it was updating. Turns out it was the latter and it’s really easy to fix, first log on to your ftp, file manager or whatever for your hosting and browse to your wordpress install, in the root of this there should be a .maintenance file, just delete this and everything should be back to normal. Once back in the WordPress dashboard you may be asked to reinstall whatever failed however sometimes it will have completed the install and just not managed to delete this file.

Categories
GIMP Posts Ubuntu

GIMP (2.6.8) Crashing On Some Toolbox Icons – Lucid

:~$ gimp
gimp: fatal error: Failed to register GObject with DBusConnection

(script-fu:3100): LibGimpBase-WARNING **: script-fu: gimp_wire_read(): error

I fixed this error by removing opening Synaptic Package Manager and searching for appmenu-gtk, right click and mark for removal, once this has been done it should begin to work again.