ModuleNotFoundError: No module named 'google'

Moved from GitHub pydgraph/80

Posted by Tails:

I’m having trouble installing pydgraph using pip, while this used to work before 2.0.0 (downgrading using pydgraph==1.2.0 does work).

Stack trace

Collecting pydgraph (from -r /runtime/app/requirements.txt (line 40))
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fejh1_9l/pydgraph/'"'"'; __file__='"'"'/tmp/pip-install-fejh1_9l/pydgraph/'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);'"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-fejh1_9l/pydgraph/
    Complete output (9 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-fejh1_9l/pydgraph/", line 33, in <module>
        from pydgraph.meta import VERSION
      File "/tmp/pip-install-fejh1_9l/pydgraph/pydgraph/", line 15, in <module>
        from pydgraph.proto.api_pb2 import Operation, Payload, Request, Response, Mutation, TxnContext,\
      File "/tmp/pip-install-fejh1_9l/pydgraph/pydgraph/proto/", line 7, in <module>
        from google.protobuf import descriptor as _descriptor
    ModuleNotFoundError: No module named 'google'

Trying to install the protobuf or google packages before dgraph (as advised on StackOverflow) doesn’t make a difference.


FROM python:3.7.0-alpine3.8

WORKDIR /runtime/app

RUN apk add --update --no-cache openssh sshpass

RUN apk -U add \
        gcc \
        g++ \
        git \
        bash \
        libffi-dev \
        libxml2-dev \
        libxslt-dev \
        libjpeg \
        jpeg-dev \
        musl-dev \
        #openssl-dev \
        python-dev \
        python3-dev \
        py-imaging \
        py3-pillow \
        py3-lxml \
        libxml2-utils \
        linux-headers \
        py-pip \
        make \
        db-dev \
        #mariadb-dev \
        mysql-dev \
        curl \
        ca-certificates \
        rsync \
        tidyhtml \
        tidyhtml-libs \
        tidyhtml-dev \
    && update-ca-certificates \
    && rm -rf /var/cache/apk/*

# TODO: automate this away by using the python-alpine-small image with onbuild
ADD ./requirements.txt /runtime/app/requirements.txt

RUN pip3 install --upgrade pip

RUN pip3 install cython

RUN pip3 install -r /runtime/app/requirements.txt #--target=/runtime/app/.packages


google-cloud #even these packages do not fix missing google module


martinmr commented :

I think this is another instance of the issue fixed by this PR: Catch pypandoc ModuleNotFoundError by robin-snt · Pull Request #81 · dgraph-io/pydgraph · GitHub

I’ll release a new version of pydgraph with that change and verify it works.

martinmr commented :

@Tails I couldn’t reproduce the issue on my machine (probably because I am not starting from an empty environment) but I released a new version of pydgraph with the fix. Can you verify it’s working again for you? version number is 2.0.1

Tails commented :

Fixed, thank you!