【问题标题】:Big Query - Local machine - ImportError: DLL load failed: The specified procedure could not be foundBig Query - Local machine - ImportError: DLL load failed: 找不到指定的过程
【发布时间】:2019-11-29 06:33:48
【问题描述】:

我无法运行执行大查询的 python 程序。 我的python版本:3.6.0 我的点子版本: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.

但是当我将其 dockerize 并将其作为任何服务(如云运行等)运行时,相同的代码运行良好。

我已转帖:ImportError: DLL load failed: The specified module could not be found 但它没有工作

这是我的代码:

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)    

我的要求.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

这是由 pip install 填充的依赖项,因为我只添加了 Flask 和 google-bigquery

我的道:

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()


有什么帮助吗?

【问题讨论】:

  • 'bqservice' 是你定义的模块吗?我无法找到有关它的文档。如果是你定义的,能不能也分享一下?
  • 是的,bqservice 是这里的一个包。该错误与我的本地环境更相关。因为当我也克隆了谷歌快速入门模块时,它失败并出现同样的错误。如果我不能在本地运行它,那么每次我推送到 CI 管道以对它进行 dockerize 和测试时,都要进行测试是一项艰巨的任务。

标签: python google-bigquery


【解决方案1】:

您的内部包“bqservice”似乎正在调用未安装的包,让您看到该错误消息。

在 GCP 资源上运行代码时不会遇到此问题,因为大多数情况下,这些包是默认安装的。

希望这有帮助。

【讨论】:

  • protobuf 已经是包的一部分,所以当我明确尝试时,它显示了该消息。但是,我已经安装了tensorflow,仍然没有工作。似乎是版本问题。我会将python升级到最新版本并将所有依赖项升级到最新版本以尝试找到解决方案。任何意见都受到高度赞赏。谢谢。
  • 让我们知道您在这些更改后的结果。我会尝试找到更多关于它的信息
  • 我已经将我的 python 版本从 3.6.x 升级到 3.8.0 和 pip 版本。现在它正在工作,所以这意味着存在版本兼容性问题。
  • 如果我写的答案解决了你的问题,请考虑接受:)
猜你喜欢
  • 2020-04-16
  • 2016-08-19
  • 2017-12-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-04
  • 1970-01-01
  • 2020-07-02
相关资源
最近更新 更多