How to Install Python 2.7.5 on N900 [Maemo 5]

Posted: 09/12/2013 in G.N.A.HackTeam, Info, Linux Hacking
Tags: , , , , , , , , , , , , , , , , , , , , , , , , ,

Maemo 5 supports python. But only the 2.5 version. People say that most Python Users haven’t even used Python features that are presented to newest Versions.

I disagree. Trying to Install some Python Modules, many times, I had these unexpected Syntax Errors while using/installing new Modules! Stable ones!

So, why not trying to install a newer Python Version? At first, there are difficulties but, then, it seems an easy Process if you are careful. Let’s see how to work this thing out…. Disclaimer: If you brick your device is not my Responsibility! This Process is really risky, so if you don’t know Maemo, do not try this! We will have to enable the Extras-Devel and Extras-Testing Repositories that can easily brick your Device if you are not Careful! (Speaking from Experience…)

This is Advanced Stuff! You have been warned!

Recommendations:

  1. Use the Faster Application Manager (downloaded from the Default App Manager)
  2. Install an SSH-Server on the Device and SSH into it. (It is MUCH more convenient this way – Search Google on how to achieve that)
  3. If you see any error that seems really Important / Risky for the System, don’t install a newer Python Version!
  4. ALWAYS BE ABLE TO flash your N900! If you brick the system, you should at least be able to restore to Factory Settings
  5. Backup your System Settings/Apps! (In case you need to flash your device)
  6. Take into Serious Consideration the previous 5 Suggestions! 🙂

I will break this How-To into segments:

  1. Downloading Necessary .deb Files
  2. Enabling Extras-Devel, Extras-Testing Repositories
  3. Installing other Necessary Packages [a. Installing .deb files | b. installing newer grep version]
  4. Download and Configuring Python Source
  5. Installing Python 2.7
  6. Installing Distribute (pip and easy_install for 2.7)

Let’s Begin!

1. Downloading Necessary .deb Files:

For all the steps I assume you have SSHed as root. If not, prepend a “sudo ” before the commands (without the quotes, of course). From the SSH Terminal, do the following:

# These will download the .debs that are necessary

# If you get an error like this ‘wget: command not found’, do: ‘apt-get install wget’

wget http://repository.maemo.org/pool/fremantle/free/b/binutils/binutils_2.18.50.20070820-4+0m5_armel.deb

wget http://repository.maemo.org/pool/fremantle/free/g/gcc-4.2/libgcc1_4.2.1-4maemo13+0m5_armel.deb

wget http://repository.maemo.org/pool/fremantle/free/g/gcc-4.2/libgomp1_4.2.1-4maemo13+0m5_armel.deb

wget http://repository.maemo.org/pool/fremantle/free/g/gcc-4.2/cpp-4.2_4.2.1-4maemo13+0m5_armel.deb

wget http://repository.maemo.org/pool/fremantle/free/g/gcc-4.2/gcc-4.2-base_4.2.1-4maemo13+0m5_armel.deb

wget http://repository.maemo.org/pool/fremantle/free/g/gcc-4.2/gcc-4.2_4.2.1-4maemo13+0m5_armel.deb

wget http://repository.maemo.org/pool/fremantle/free/k/kernel/linux-kernel-headers_2.6.28-20094803.3+0m5_armel.deb

wget http://repository.maemo.org/pool/fremantle/free/g/glibc/libc6-dev_2.5.1-1eglibc27+0m5_armel.deb

wget http://repository.maemo.org/pool/fremantle/free/g/gcc-4.2/libstdc++6_4.2.1-4maemo13+0m5_armel.deb

wget http://repository.maemo.org/pool/fremantle/free/g/gcc-4.2/libstdc++6-4.2-dev_4.2.1-4maemo13+0m5_armel.deb

wget http://repository.maemo.org/pool/fremantle/free/g/gcc-4.2/g++-4.2_4.2.1-4maemo13+0m5_armel.deb

wget http://repository.maemo.org/extras-devel/pool/fremantle/free/m/make-3.81/make-3.81_3.81-maemo3_armel.deb

Note this: Later, we will install from the Faster App Manager a newer grep version. (grep-gnu package). If you get DEPENDENCY errors, check the Manager’s Log file. If it conflicts at these files, don’t hesitate to change the links from ‘maemo13’ to the according ‘maemoNR’, where NR is the correct number. (Wherever maemo13 is available, not the last package!)

2. Enable the Extras-Devel and Extras-Testing Repos:

At the Faster Application Manager at your N900, go to Manage Repositories -> New and add the following.

Name: Maemo Extras-Devel

URL: http://repository.maemo.org/extras-devel/

Distribution: fremantle

Components: free non-free

Enabled: CHECK

And again, one New Repo:

Name: Maemo Extras-Testing

URL: http://repository.maemo.org/extras-testing/

Distribution: fremantle

Components: free non-free

Enabled: CHECK

3. Installing other Necessary Packages:

a. Installing .deb files

Back on the SSH Terminal do the following:

ls -l | awk ‘{print $9}’  # This should print all the Packages Downloaded.

Now, for each one (except libstdc++6-4.2-dev_4.2.1-4maemo13+0m5_armel.deb and g++-4.2_4.2.1-4maemo13+0m5_armel.deb) do this:

dpkg -i PACKAGE_NAME

Now, to Install g++, we need to do this:

dpkg --unpack libstdc++6-4.2-dev_4.2.1-4maemo13+0m5_armel.deb

dpkg --unpack g++-4.2_4.2.1-4maemo13+0m5_armel.deb

# and then

dpkg -i libstdc++6-4.2-dev_4.2.1-4maemo13+0m5_armel.deb

dpkg -i g++-4.2_4.2.1-4maemo13+0m5_armel.deb

Also, we need to install make, so we do:

dpkg -i make-3.81_3.81-maemo3_armel.deb

b. installing newer grep version

On the Faster Application Manager again, we need to install a newer version of the grep command, since it is required from the Python configure Script. Go to “Install Applications” and Search for “grep-gnu”. Install that Package. (If it doesn’t show up, you haven’t Enabled the Devel-Extras and Testing Repos! – Yes, you have to let it Update the Catalogs after Enabling them!)

4. Download and Configuring Python Source:

Back to the SSH Terminal, do this:

# Download Python Source Tarball

wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tgz

tar -zxvf Python-2.7.5.tgz

cd Python-2.7.5

Let’s Enable zlib Support First:

nano Modules/Setup.dist

# Now Press: CTRL+W

# Type: zlib

# uncomment the line:    – Uncomment by removing the # before that line –

zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz

# Press CTRL + X -> Y

# Done…

And to Configure the Python Source type this:

./configure –prefix=/usr

It takes time so wait…

Theoretically, it won’t show any Errors, but if it does, let me know. If no errors are shown and the configuration is completed, we may continue to Installation.

5. Installing Python:

I should really congratulate you for reaching this point! Most times, the configuration goes bad! The rest should run without any problems. So to Install Python 2.7.5 we do:

make                        # The make command takes a lot of time (!!!), since Python is a big File to handle.

#  It is absolutely normal.

make install           # This also takes time but much less than the configuration script. (less than 4-5 mins)

rm /usr/bin/python

ln /usr/bin/python-2.7 /usr/bin/python

Yoohooo! We did it! 😉

Maemo_5_Python27

6. Disable the Extras-Devel and Extras-Testing Repos:

Do not forget to disable the Repos we Enabled from the Faster Application Manager! You may brick your system if you are not careful!

7. Install Distribute (pip and easy_install):

Do the following:

wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz

tar -vzxf distribute-0.6.35.tar.gz

cd distribute-0.6.35

python2.7 setup.py install

Say a great Thank you to the Maemo Community for helping ANY Problem with the N900 and for creating so great Applications on this Unique Device!

I would really like to see people installing successfully Python 2.6 or 2.7 on their Devices! Please Commend if you made it, if you are stuck somewhere, if you think I did something wrong or whatever you think!

– akatzbreaker

Advertisements
Comments
  1. Post Updated:
    Now you can install Distribute (pip and easy_install commands) successfully for 2.7 (or 2.6), to install new Modules!

    Have Fun!

    • jack says:

      hello,i have a problem.
      I still haven’t got past that. I get this output:

      /home/user/MyDocs/n900python/Python-2.7.5 # ./configure -prefix=/usr

      checking build system type… armv7l-unknown-linux-gnueabi
      checking host system type… armv7l-uknown-linux-gnueabi
      checking for –enable-universalsdk… no
      checking for –with-universal-archs… 32-bit
      checking MACHDEP… linux2
      checking EXTRAPLATDIR…
      checking for –without-gcc… no
      checking for gcc… gcc
      checking whether the C compiler works… yes
      checking for C compiler default output file name… a.out
      checking for suffix of executables…
      checking whether we are cross compiling… configure:error:in ‘/home/user/MyDocs/n900python/python-2.7.5’:
      configure: error: cannot run C compiled programs.
      if you meant to cross compile, use ‘–host’.
      See `config.log’ for more details

    • jack says:

      hello, can you help me?

      I still haven’t got past that. I get this output:

      /home/gox/python-2.7-files/Python-2.7.5 # ./configure -prefix=/usr

      checking build system type… ./config.guess: line 892: echo: write error: Broken pipe
      ./config.guess: line 897: echo: write error: Broken pipe
      armv7l-unknown-linux-gnueabihf
      checking host system type… armv7l-unknown-linux-gnueabihf
      checking for –enable-universalsdk… no
      checking for –with-universal-archs… 32-bit
      checking MACHDEP… linux2
      checking EXTRAPLATDIR…
      checking for –without-gcc… no
      checking for gcc… no
      checking for cc… no
      checking for cl.exe… no
      configure: error: in `/home/gox/python-2.7-files/Python-2.7.5′:
      configure: error: no acceptable C compiler found in $PATH
      See `config.log’ for more details

    • jack says:

      hello,guy can you help me ?

      I still haven’t got past that. I get this output:

      /home/user/MyDocs/n900python/Python-2.7.5 # ./configure -prefix=/usr

      checking build system type… armv7l-unknown-linux-gnueabi
      checking host system type… armv7l-uknown-linux-gnueabi
      checking for –enable-universalsdk… no
      checking for –with-universal-archs… 32-bit
      checking MACHDEP… linux2
      checking EXTRAPLATDIR…
      checking for –without-gcc… no
      checking for gcc… gcc
      checking whether the C compiler works… yes
      checking for C compiler default output file name… a.out
      checking for suffix of executables…
      checking whether we are cross compiling… configure:error:in ‘/home/user/MyDocs/n900python/python-2.7.5’:
      configure: error: cannot run C compiled programs.
      if you meant to cross compile, use ‘–host’.
      See `config.log’ for more details

  2. Hey,

    You should replace “./configure –prefix=/usr” with “./configure -prefix=/usr”
    The wrong line character made “invalid variable name” error when copy pasteing.

    But I still haven’t got past that. I get this output:

    /home/gox/python-2.7-files/Python-2.7.5 # ./configure -prefix=/usr

    checking build system type… ./config.guess: line 892: echo: write error: Broken pipe
    ./config.guess: line 897: echo: write error: Broken pipe
    armv7l-unknown-linux-gnueabihf
    checking host system type… armv7l-unknown-linux-gnueabihf
    checking for –enable-universalsdk… no
    checking for –with-universal-archs… 32-bit
    checking MACHDEP… linux2
    checking EXTRAPLATDIR…
    checking for –without-gcc… no
    checking for gcc… no
    checking for cc… no
    checking for cl.exe… no
    configure: error: in `/home/gox/python-2.7-files/Python-2.7.5′:
    configure: error: no acceptable C compiler found in $PATH
    See `config.log’ for more details

    My config.log file: http://pastebin.com/FE59QUyB

    I’m trying to install this new version of python to run goxtool application.

  3. Hey,

    I got rid of configure errors by pointing the location of gcc-4.2.

    Now I’m trying to compile it (make) and I got “no space left on device” errors and I changed the temp folder to MyDocs but still didn’t succeed – I get other errors now:
    http://pastebin.com/raw.php?i=fZBMUrFm

  4. OK,

    I fixed compile errors by doing this:

    wget http://repository.maemo.org/pool/fremantle/free/z/zlib/zlib1g-dev_1.2.3-9.osso9%2b0m5_armel.deb

    dpkg -i zlib1g-dev_1.2.3-9.osso9\+0m5_armel.deb

    Then I got errors like this during “make install”:

    File “/usr/lib/python2.7/test/test_unicode.py”, line 1642
    self.assertEqual(unicode_encodedecimal(u”\N{EM SPACE}3.14\N{EN SPACE}”),
    SyntaxError: (unicode error) \N escapes not supported (can’t load unicodedata module)

    I opened Modules/Setup.dist file again and uncommented this line below:

    #unicodedata unicodedata.c # static Unicode character database

    Configured it little differently:
    CC=/usr/bin/gcc-4.2 ./configure -prefix=
    /usr –enable-unicode=ucs2

    Ran make again.. Success

    Make install:
    TMPDIR=/home/user/MyDocs/tmp/ make install

    Ok, no errors now. But I don’t have python-2.7 in /usr/bin.. Wtf?

  5. Ahh, the install script did the replacing of old version with new automatically so I just removed it by doing what’s written in your tutorial.

    Thanks, it works now! But some updating needed in the tutorial haha.

  6. <<<AsdAsadasd. Still getting this error with some scripts. I tried uncommenting _collections at Setup.dist and configure+compile again but no help.

    ~/goxtool $ python goxtool.py
    Traceback (most recent call last):
    File "goxtool.py", line 26, in
    import argparse
    File “/usr/lib/python2.7/argparse.py”, line 85, in
    import collections as _collections
    File “/usr/lib/python2.7/collections.py”, line 8, in
    from _collections import deque, defaultdict
    ImportError: No module named _collections

  7. Rayan says:

    Hello my firend I have a problom in ./configure -prefix=/usr Error occurs?Says Permiision deied! why?

  8. Rayan says:

    I have gainroot but again do not ?why please hellp me I need install python new version

  9. Rayan says:

    OMGD it gives error

    user is not in the sudoers file . This incident will be reported.

  10. Avasz says:

    Hi, it’s 2016, but still N900 works fine.
    Maybe you can add this somewhere as a note, if “no acceptable c compiler found in $path” error occurs even after doing everything then this will solve it:

    CC=/usr/bin/gcc-4.2 ./configure –prefix=/usr

    Even if you do not add this, this comment will work for others or for myself too if I need to compile it ever egain. 😀

    • jack says:

      hello,
      Nokia N900 install python2.7 i have a problem.
      I still haven’t got past that. I get this output:

      /home/user/MyDocs/n900python/Python-2.7.5 # ./configure -prefix=/usr

      checking build system type… armv7l-unknown-linux-gnueabi
      checking host system type… armv7l-uknown-linux-gnueabi
      checking for –enable-universalsdk… no
      checking for –with-universal-archs… 32-bit
      checking MACHDEP… linux2
      checking EXTRAPLATDIR…
      checking for –without-gcc… no
      checking for gcc… gcc
      checking whether the C compiler works… yes
      checking for C compiler default output file name… a.out
      checking for suffix of executables…
      checking whether we are cross compiling… configure:error:in ‘/home/user/MyDocs/n900python/python-2.7.5’:
      configure: error: cannot run C compiled programs.
      if you meant to cross compile, use ‘–host’.
      See `config.log’ for more details

  11. OAK LED Co ,Limited specialized in high power led lighting for stadium We offer 100 2000w LED Football Stadium Light With one of the top football stadium light manufacturers and suppliers, we produce high quality products with reliable quality led stadium light

  12. OAK LED Co ,Limited is one of the top level China high power LED flood light manufacturers and suppliers with one of the famous high power LED flood light brands, as a professional company, we have our own factory, which is able to produce high quality products with reliable quality high power led flood light

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s