简体   繁体   English

在Google App Engine Python 2.7上安装opencv

[英]Install opencv on Google App Engine Python 2.7

Hi I installed on a Google App Engine Python 2.7, opencv using 嗨我安装在Google App Engine Python 2.7上,opencv使用

pip install -t lib -r requirements.txt

requirements.txt is: requirements.txt是:

Flask==0.12.1
Werkzeug==0.12.2
Opencv_python==3.3.0.10

Install worked, I can use other libraries, but when I try to import opencv on code, it throws the next exception: 安装工作,我可以使用其他库,但当我尝试在代码上导入opencv时,它会抛出下一个异常:

  File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/home/tcarrillof/python-docs-hello-world/main.py", line 23, in <module>
    import cv2
  File "/home/tcarrillof/python-docs-hello-world/lib/cv2/__init__.py", line 6, in <module>
    os.environ["PATH"] += os.pathsep + os.path.dirname(os.path.realpath(__file__))
  File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/request_environment.py", line 126, in __getitem__
    return self._request.environ[key]
KeyError: 'PATH'

Is it there something I need to configure?, Any help is welcome in advance :) 是否有我需要配置的东西?,提前欢迎任何帮助:)

Note: 注意:

app.yaml is: app.yaml是:

runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /static
  static_dir: static
- url: /.*
  script: main.app

and appengine_config.py is: 和appengine_config.py是:

import os
from google.appengine.ext import vendor

vendor.add(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib'))

This is less something you need to configure, and more something to abandon. 这不是你需要配置的东西,而是更多的东西要放弃。 OpenCV won't run in the standard App Engine environment. OpenCV不会在标准的App Engine环境中运行。 OpenCV is a big chunk of C++ (with Python wrappers). OpenCV是C ++的一大块(使用Python包装器)。 App Engine only supports libraries that are pure Python unless they're on the list in https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27 App Engine仅支持纯Python库,除非它们位于https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27列表中

If you need OpenCV, consider using the Flex environment. 如果您需要OpenCV,请考虑使用Flex环境。

You could try using Cloud Function which might make life simpler 您可以尝试使用可能使生活更简单的云功能

You can see in Support Python in Cloud Functions the last comment you can find a link to this cloud-functions-python 您可以在支持Python的云函数中看到最后一条评论,您可以找到这个cloud-functions-python的链接

You can just list opencv as one libraries required along with other libraries such as numpy and matplotlib generally used along with any others you might actually want to use. 您可以将opencv列为一个所需的库以及其他库,例如numpymatplotlib以及您可能实际想要使用的任何其他库。

How to install OpenCV using pip here's a nice answer I found on stackoverflow answers 如何使用pip安装OpenCV这是我在stackoverflow答案中找到的一个很好的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM