2

I have an embedded system running on Python 2.6.5 and i want it to upgrade to 2.7.2 (I have a running system with different kernel that runs 2.7.2). I have copied the binary but then it told me: python: can't load library 'libpython2.7.so.1.0' when i tried to launch it - fine, i grabbed and copied that as well and now I get:

# python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Segmentation fault

How can I get this system upgraded to Python 2.7.2 while keeping the old, original kernel — I only want to update Python, not the whole image — possible?

  • 1
    You'll need to install the new Python from scratch. Choose an install location of your choice and set PYTHONHOME environment variable to its location. – mkc Jan 11 '14 at 22:21
  • @Ketan ... from scratch...? Should I not just be able to copy files from my system A to system B (A being the system with Python 2.7.2 running, B is the system that I want to upgrade) – cerr Jan 12 '14 at 0:13
  • If you actually mention your operating system, architecture etc, it would be easier to find an answer... – Wilf Jan 12 '14 at 1:31
  • 1
    AFAIK no. Assuming it is a Linux box, I'd advise you to install python 2.7.2 from source. It is quite straightforward to do so. – mkc Jan 12 '14 at 1:32
  • @wilf It is a busybox compiled Linux system on a small ARM9 embedded platform (AT91SAM9G20). Sorry to not have been clear before - this is for both systemns, A and B – cerr Jan 12 '14 at 2:07
5

If the systems are similar, like you indicated in your comments, then this is quite possible to do. What you are likely to miss is /usr/lib/python2.7 or /usr/local/lib/python2.7, and the files beneath that—if you copied the executable python2.7 from /usr/bin then most likely the former, if copied from /usr/local/bin most likely the latter.

You can specify configuration options when compiling Python on Linux for many parts (--bindir for executable, --mandir man pages, etc.), but most likely you did not specify any and just did ./configure before running make. If your run ./configure --help you can see what the default value for --prefix is, the rest is relative to that, but other files will be there as well.

To find out everything you can touch all of the source, compile and install and find (starting with the default directory for configure's --prefix option), anything installed the last X minutes.

You could also recompile to a specify unused directory by specifying --prefix to configure, that way there will be no other files than those you need to copy:

 cd Python-2.7.2
 make clean  # might fail ignore
 ./configure --prefix=/opt/py272
 make
 sudo make install

After that you can tar up everything under /opt/py272 (assuming there was nothing there before you started the compilation) and copy it to the target system and extract things to /opt/py272.

On the target system you can also link /usr/bin/python27 to /opt/py272/bin/python so you can use the line #! /usr/bin/env python27 atop your 2.7.2 specific scripts.

In all of this you need to know you are not free to move files around from the location specified at configuration time, as some paths are compiled into the executable/libraries, but you can link to the executable from a sensible place (some directory in your $PATH).

  • Okay, I copied /usr/lib/python2.7 over and now I get # python \nIllegal instruction what is that about, I'm wondering – cerr Jan 13 '14 at 1:29
  • @cerr And this runs on system A where it is compiled? And A has the same OS and has the same processor as B? I am not sure why you are cross compiling, and this seems like an ARM processor mismatch to me, but it is difficult going through the info—scattered in the comments to your OP (IMHO you should have included much of that info in the question and just notify the commentors that you did do so). – Anthon Jan 13 '14 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.