I have a python code (Running on a raspbian OS) which reads the value of a joystick axis and then sends the value to an arduino.

At the start of the code I have typed:

import pygame

I can then use functions defined inside pygame, such as get_axis(). This all works fine.

My problem is that the get_axis() function prints the value on the python shell and LXTerminal, which is not what I want.

All of the pygame files are located in the folder:


And I know that the function I want is located inside:


But how do I open and edit this shared object file?

  • You don't, or at least, not directly. A .so file is a compiled library, i.e., it does not contain any python source. These are needed to wrap system calls and other C interface stuff. However, I'm not a python user and don't know the nitty gritty; there should be the source for this somewhere (note, it will be at least partially in C) and you could modify that and recompile. I've changed your title to better reflect what information you are looking for. This might actually be better on Stack Overflow.
    – goldilocks
    Nov 17 '14 at 13:57
  • 3
    Come over to StackOverflow and show us your code. There's nothing wrong with get_axis(), you're just using it wrong. We'll need to see a small code example in order to show you how to fix your mistake. But I bet get_axis() is printing its result because you're calling the function in the interactive interpreter without assigning the result to a variable, so the interpreter is simply printing the result.
    – PM 2Ring
    Nov 17 '14 at 14:16
  • Have you familiarised yourself with the Pygame docs and started working through the tutorials?
    – PM 2Ring
    Nov 17 '14 at 14:19
  • @PM2Ring Thank you. I have posted the question here
    – Blue7
    Nov 17 '14 at 15:41

You normally don't edit a shared object file, you compile it from the sources after editing it.

You can download the sources for pygame, the latest released sources are http://pygame.org/ftp/pygame-1.9.1release.tar.gz.

If you download that, the actual sources for the joystick.so are under src/joystick.c. Compilation/installation is not done via the common ./configure, make and make install routines as this is a Python package. In order to compile/install you call:

python setup.py install 

in the base directory of the extracted tar file.

The compilation depends on several packages, unfortunately there is no clear overview of what needs to be installed (smpeg, videodev.h), so it might require some searching in order to get that to install, depending on how clean your machine is to start with.


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.