1

I am not able to run my python program that executes big query. My python version: 3.6.0 My pip version: 19.3.1

Traceback (most recent call last):
  File "app.py", line 2, in <module>
    from bqservice import query_service
  File "C:\work\python-bigquery\bqservice\query_service.py", line 1, in <module>
    from google.cloud import bigquery
  File "C:\work\python-bigquery\env\lib\site-packages\google\cloud\bigquery\__init__.py", line 35, in <module>
    from google.cloud.bigquery.client import Client
  File "C:\work\python-bigquery\env\lib\site-packages\google\cloud\bigquery\client.py", line 50, in <module>
    import google.cloud._helpers
  File "C:\work\python-bigquery\env\lib\site-packages\google\cloud\_helpers.py", line 33, in <module>
    from google.protobuf import duration_pb2
  File "C:\work\python-bigquery\env\lib\site-packages\google\protobuf\duration_pb2.py", line 5, in <module>
    from google.protobuf import descriptor as _descriptor
  File "C:\work\python-bigquery\env\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.

But the same code works well when I dockerize it and run it as any service like cloud run etc.

I have referred the post: ImportError: DLL load failed: The specified module could not be found But it did not work

Here is my code:

from flask import Flask, request, jsonify
from bqservice import query_service


# Init App
app = Flask(__name__)


@app.route('/', methods=['GET'])
def home():
    return "Home page"


@app.route('/match/<id>', methods=['GET'])
def get_a_project(id):
    match_summary = query_service.get_match_details(id)    
    return match_summary


 # This is for debug mode on
if __name__ == '__main__':
    app.run( port=8080, debug=True)    

My requirements.txt

cachetools==3.1.1
certifi==2019.9.11
chardet==3.0.4
Click==7.0
Flask==1.1.1
google-api-core==1.14.3
google-auth==1.7.1
google-cloud-bigquery==1.22.0
google-cloud-core==1.0.3
google-resumable-media==0.5.0
googleapis-common-protos==1.6.0
idna==2.8
itsdangerous==1.1.0
Jinja2==2.10.3
MarkupSafe==1.1.1
protobuf==3.11.0
pyasn1==0.4.8
pyasn1-modules==0.2.7
pytz==2019.3
requests==2.22.0
rsa==4.0
six==1.13.0
urllib3==1.25.7
Werkzeug==0.16.0

This was dependencies were populate by pip install as I added only Flask and google-bigquery

My dao:

from google.cloud import bigquery
from os import environ
from baseball import matches


def get_match_details(gameId):

    client = bigquery.Client()

    query_job = client.query("select * from `bigquery-public-data.baseball.schedules` where gameid= '"+gameId+"'")

    results = query_job.result()  # Waits for job to complete.


    for row in results:  # API request - fetches results
        requested_match = matches.Matches(row["homeTeamName"], row["awayTeamName"], row["dayNight"], row["startTime"], row["attendance"], row["duration"])



    return requested_match.get_details()


Any help?

davidism
  • 121,510
  • 29
  • 395
  • 339
ARINDAM BANERJEE
  • 659
  • 1
  • 8
  • 29
  • Is 'bqservice' a module you defined? I was unable to find docs about it. If it was defined by you, could you please share it as well? – Kevin Quinzel Nov 27 '19 at 19:22
  • Yes, bqservice is a package here. The error is more related to my local environment. Because when I cloned the google quickstart module also, it fails with the same error. If I can't run it locally it becomes a daunting task to test every time I push to CI pipeline to dockerize and test it. – ARINDAM BANERJEE Nov 28 '19 at 09:05

1 Answers1

0

It seems that your internal package 'bqservice' is calling a not installed package making you to see that error message.

You don't experience this issue when running the code on a GCP resources because, most of the time, those packages are installed by default.

Hope this is helpful.

Kevin Quinzel
  • 1,430
  • 1
  • 13
  • 23
  • 1
    protobuf was already part of the package, so when I explicitly tried, it showed that message. however, I have installed tensorflow, still did not work. seems to be a version issue. I will upgrade the python to latest version and upgrade all dependencies to latest to try and find the solution. any input is highly appreciated. thanks. – ARINDAM BANERJEE Nov 29 '19 at 13:17
  • Let us know your outcome after those changes. I'll try to find more info about it – Kevin Quinzel Nov 29 '19 at 19:38
  • 2
    I have upgrade my python version from 3.6.x to 3.8.0 and pip version as well. Now it is working, so it mean there were version compatibility issue. – ARINDAM BANERJEE Dec 02 '19 at 09:59
  • If the answer I wrote solved your issue, please consider accepting it :) – Kevin Quinzel Dec 12 '19 at 01:34