1

I'm trying to run the benchmarks game repo bencher script which was written in python 2 and requires the gtop module, NOT the pygtop module. After searching everywhere and even following their README.md I could not figure out how to get this in my python 2.7.18 virtual environment (created and maintained using pyenv).

I decided to have a look at my system version of python 2.7.18 as I followed the guide from this SO reply and the packages downloaded/installed successfully. My system version of python can import the module just fine:

Python 2.7.18 (default, Mar  8 2021, 13:02:45) 
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtop
>>> gtop.__file__
'/usr/lib/python2.7/dist-packages/gtk-2.0/gtop.so'

So apparently it comes as a .so which I've researched is like a DLL library for Ubuntu (correct me if I'm wrong)?

Is there a way for me to just copy this into my virtual environment of the same python version?

Mario
  • 339
  • 4
  • 17
  • 2
    There seems to be a similar issue with python-dbus here: https://stackoverflow.com/a/13710008/1581658 is that any help for which files to copy into your virtual env? – SamBob Oct 24 '21 at 21:12
  • And you are correct, an `.so` is the Linux equivalent of a `DLL` They are both known as shared libraries. (There are some differences in how they work - but they fulfill the same task - providing compiled code that can be loaded by other running programs) – SamBob Oct 24 '21 at 21:15
  • 1
    @SamBob thank you for providing a link! I believe something similar was the solution. Basically what I've been doing is copying the `gtk-2.0` directory into my virtualenvs `site-packages` directory. What I've done is instead copy just the `gtop.so` directly into the virtualenvs `site-packages` directory and it seemed to recognise it no problem. Extremely odd how it only recognises the package if it's standalone under `site-packages`... – Mario Oct 25 '21 at 17:34

1 Answers1

1

Thank you to @SamBob for suggesting the SO reply that led to the answer.

What I've been mistakenly doing is copying the gtk-2.0 directory into my virtualenvs site-packages such that:

$HOME/.pyenv/versions/<venv>/lib/python2.7/site-packages/gtk-2.0/gtop.so

What I've done is instead copy just the gtop.so library into the virtualenvs site-packages, and it seemed to recognise it no problem, such that

$HOME/.pyenv/versions/<venv>/lib/python2.7/site-packages/gtop.so

Here is my output now:

Python 2.7.18 (default, Oct 18 2021, 23:18:58) 
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtop
>>> gtop.__file__
'/home/muffin/.pyenv/versions/project-2.7.18/lib/python2.7/site-packages/gtop.so'
>>> 
Mario
  • 339
  • 4
  • 17