Debian (stretch) install ModuleNotFoundError with Py3

I am trying to create a Docker image with graph-tool installed along with a
number of geospatial C libraries with Debian stretch OS. Everything but
graph-tool has been set up, and is available here (
https://hub.docker.com/r/kuanb/peartree/).

The Dockerfile to create that image can be viewed here (
https://github.com/kuanb/peartree/blob/ea45bdd0a045c1bb7769f88801b5dab85c3f9d46/docker/Dockerfile
).

I attempt to install graph-tool in a container from the above image with
the following:

sed -i -e '$a\
deb http://downloads.skewed.de/apt/stretch stretch main\
deb-src http://downloads.skewed.de/apt/stretch stretch main'
/etc/apt/sources.list && \
apt-get update && \
apt-get install python3-graph-tool

This appears to be successful. I then go into a Python3 repl and
attempt to import
graph_tool which results in a ModuleNotFoundError.

I suspect the error has to do with versions of Python3 and where the
library (graph-tool) is being placed versus where pip is placing its
libraries. Unfortunately, I am not entirely confident navigating this and
would be appreciative of any guidance - I suspect I am "almost there" and
someone on this list may be more familiar with setting this up and could
point me in the right direction.

Thanks in advance and happy new year. :slight_smile:

attachment.html (2.56 KB)

An update:

Attempting the following:
cp -r /usr/lib/python3/dist-packages/*
/usr/local/lib/python3.6/site-packages/

Resulted in this error:
ModuleNotFoundError: No module named 'scipy.special._ufuncs'

The following results in the same issue.
export PYTHONPATH="${PYTHONPATH}:/usr/lib/python3/dist-packages/"

attachment.html (3.91 KB)

That's terrible. Don't move around the _entire_ standard python library like
that, you are guaranteed to break things.

Why are things in /usr/local? Do you have a custom Python install?

Yes, it was a bad idea. Sorry I shared it out.

The image that my works is based off of is the official repository for
Python on Docker Hub (FROM python:3.6-stretch). Link to the Dockerfile to
build my image:
https://github.com/kuanb/peartree/blob/a202d216abb7b1dab77d84602862dcf02bd91a65/docker/Dockerfile#L1

As to your question as to if this is a custom Python install - I would
assume not? If it was, then that would have been set within the
instructions for creating that python:3.6-stretch image. It does appear
that Python is aware only of packages in /usr/local.

Re: my original issue. It turns out the ModuleNotFound error stemmed from
/usr/lib/python3/dist-packages/ having older versions of Numpy and Scipy.
Adding the PYTHONPATH first, then upgrading Numpy and Scipy (numpy==1.14.0
scipy==1.0.0) allowed me to import graph_tool successfully (and have it be
able to import the various dependencies it was err'ing on before).

If you have thoughts about the different versions of Python and some
cursory familiarity with the configuration of that Python 3.6 image; I'd be
interested in finding a less awkward solution than what I did to get
graph_tool up and running. Otherwise, I'd label this issue as "resolved."
Thanks.

attachment.html (1.96 KB)

Yes, it was a bad idea. Sorry I shared it out.

The image that my works is based off of is the official repository for
Python on Docker Hub (FROM python:3.6-stretch). Link to the Dockerfile to
build my
image: https://github.com/kuanb/peartree/blob/a202d216abb7b1dab77d84602862dcf02bd91a65/docker/Dockerfile#L1

As to your question as to if this is a custom Python install - I would
assume not? If it was, then that would have been set within the instructions
for creating that python:3.6-stretch image. It does appear that Python is
aware only of packages in /usr/local.

That can't be. The default Debian python install would never look in
/usr/local. It must be a custom install done in the docker image you are
referencing.

Re: my original issue. It turns out the ModuleNotFound error stemmed
from /usr/lib/python3/dist-packages/ having older versions of Numpy and
Scipy. Adding the PYTHONPATH first, then upgrading Numpy and Scipy
(numpy==1.14.0 scipy==1.0.0) allowed me to import graph_tool successfully
(and have it be able to import the various dependencies it was err'ing on
before).

I don't see how that would happen, but I'm glad it is working.

If you have thoughts about the different versions of Python and some cursory
familiarity with the configuration of that Python 3.6 image; I'd be
interested in finding a less awkward solution than what I did to get
graph_tool up and running. Otherwise, I'd label this issue as "resolved.

Just installing from a clean Debian install using the steps explained in the
graph-tool website should just work. The issues you describe seem to be due
to a custom python install.

Best,
Tiago