1

I am running meson build which requires a number of python3 libraries to be installed. On my system a default python3 installation is currently pointing to

$ which python3
/home/myuser/anaconda3/bin/python3

The build requires python3-gi package to be installed, which is already installed using synaptic package manager

apt-cache policy python3-gi
python3-gi:
  Installed: 3.22.0-2
  Candidate: 3.22.0-2
  Version table:
 *** 3.22.0-2 500
        500 http://ftp.pl.debian.org/debian stretch/main amd64 Packages
        100 /var/lib/dpkg/status

I am not sure for which installation this package was installed, as I have also other python3 installations:

   $ whereis python3
    python3: /usr/bin/python3.5m-config /usr/bin/python3.5 /usr/bin/python3.5-config /usr/bin/python3.5m /usr/bin/python3 /usr/lib/python3.5 /usr/lib/python3 /etc/python3.5 /etc/python3 /usr/local/lib/python3.5 /usr/include/python3.5 /usr/include/python3.5dm /usr/include/python3.5m /usr/share/python3 /home/myuser/anaconda3/bin/python3.7m /home/myuser/anaconda3/bin/python3.7m-config /home/myuser/anaconda3/bin/python3.7 /home/myuser/anaconda3/bin/python3.7-config /home/myuser/anaconda3/bin/python3 /usr/share/man/man1/python3.1.gz

The error from meson I am getting is as follows:

Program python3 found: YES (/home/myuser/anaconda3/bin/python3)

meson.build:244:4: ERROR:  Problem encountered: Error: missing dependency python gobject introspection (python3-gi)

The error is generated because the build is running the following code to check if the python dependencies are installed:

    #!/usr/bin/python3

    import sys
    import os
    err = 0

    try:
        import gi
    except ImportError:
        print("Error: missing dependency python gobject introspection (python3-gi)")
        err = 1
sys.exit(err)

I have no clue how to fix this, I suspect that python3-gi package was installed into the system python3 locations but the default is pointing to anaconda installation so it is not recognized when meson build script calls it.

I am not an experienced Linux user nor I am not keen very keen on python so I need your advice how to fix this in order not to mess with the Anaconda installation. The goal is to successfully complete the build and keep the current configuration.

EDIT:

The PATH variable is as follows (I suspect that the order of directories matter):

echo $PATH
/home/sebastian/anaconda3/bin:/home/sebastian/perl5/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

EDIT 2:

The part of the meson build that is searching for python3 is as follows:

python3 = find_program('python3')
  r = run_command([python3, 'po/test-deps'])
  if r.returncode() != 0
    error(r.stdout())
  endif
Sebastian Widz
  • 1,962
  • 4
  • 26
  • 45

2 Answers2

0

Is command update-alternatives (https://manpages.debian.org/jessie/dpkg/update-alternatives.8.en.html) you can use it.

Maybe this will be helpfull: How to update-alternatives to Python 3 without breaking apt?

EDIT:

I better solution. Use virtualenv (https://pypi.org/project/virtualenv/). This command will create you env with python version from path.

  1. virtualenv --python=/path/to/python <name of project>
  2. cd <name of project>
  3. source bin/activate

After this steps you are will be in virtual env with. Use pip to install requirments.

Mikołaj
  • 59
  • 6
0

I changed the meson.build file, the part where the script searches for python3.

The standard script was running find_program() function for which the reference is here

I have change it in order to first lookup python3 in default system location and next just lookup the program by name:

Was:

python3 = find_program('python3')

After update:

python3 = find_program('/usr/bin/python3','python3')

It solved the issue.

Sebastian Widz
  • 1,962
  • 4
  • 26
  • 45