我正在使用带有Python的Google App Engine来托管一些后端脚本并将数据存储在数据存储区中,我需要利用openCV进行更高级的媒体操作。
我正在尝试切换到Google Cloud VM平台,但我无法理解如何安装openCV。
今天早些时候,在VM Cloud Shell上我试过了:
sudo apt-get install python-opencv
这似乎有效,在列出我的python模块之后我得到了:
help> modules
Please wait a moment while I gather a list of all available modules...
/usr/local/lib/python2.7/dist-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.
"You should import from ipykernel or jupyter_client instead.", ShimWarning)
BaseHTTPServer audiodev importlib setuptools
Bastion audioop imputil sgmllib
CDROM autoreload inspect sha
CGIHTTPServer base64 io shelve
Canvas bdb ipython_genutils shlex
ConfigParser binascii itertools shutil
Cookie binhex json signal
DLFCN bisect keyword simplegeneric
Dialog bsddb lib2to3 site
DocXMLRPCServer bz2 linecache sitecustomize
FileDialog cPickle linuxaudiodev six
FixTk cProfile locale smtpd
HTMLParser cStringIO logging smtplib
IN calendar macpath sndhdr
IPython cgi macurl2path socket
MimeWriter cgitb mailbox spwd
Queue chardet mailcap sqlite3
ScrolledText chunk markupbase sre
SimpleDialog cmath marshal sre_compile
SimpleHTTPServer cmd math sre_constants
SimpleXMLRPCServer code md5 sre_parse
SocketServer codecs meld3 ssl
StringIO codeop mercurial stat
TYPES collections mhlib statvfs
Tix colorama mimetools storemagic
Tkconstants colorsys mimetypes string
Tkdnd commands mimify stringold
Tkinter compileall mmap stringprep
UserDict compiler modulefinder strop
UserList contextlib multifile struct
UserString cookielib multiprocessing subprocess
_LWPCookieJar copy mutex sunau
_MozillaCookieJar copy_reg netrc sunaudio
__builtin__ crcmod new supervisor
__future__ crypt nis symbol
_abcoll csv nntplib sympyprinting
_ast ctypes ntpath symtable
_bisect curses nturl2path sys
_bsddb cv numbers sysconfig
_codecs cv2 numpy syslog
_codecs_cn cythonmagic oauth2client tabnanny
_codecs_hk datetime opcode tarfile
_codecs_iso2022 dbhash operator telnetlib
_codecs_jp dbm optparse tempfile
_codecs_kr debconf os termios
_codecs_tw decimal os2emxpath test
_collections decorator ossaudiodev test_path
_csv difflib parser tests
_ctypes dircache path textwrap
_ctypes_test dis pdb this
_curses distlib pexpect thread
_curses_panel distutils pickle threading
_elementtree doctest pickleshare time
_functools dumbdbm pickletools timeit
_hashlib dummy_thread pip tkColorChooser
_heapq dummy_threading pipes tkCommonDialog
_hotshot easy_install pkg_resources tkFileDialog
_io email pkgutil tkFont
_json encodings platform tkMessageBox
_locale ensurepip plistlib tkSimpleDialog
_lsprof errno popen2 toaiff
DocXMLRPCServer bz2 linecache sitecustomize
_markerlib exceptions poplib token
_md5 fcntl posix tokenize
_multibytecodec filecmp posixfile trace
_multiprocessing fileinput posixpath traceback
_osx_support fnmatch pprint traitlets
_pyio formatter profile ttk
_random fpectl pstats tty
_sha fpformat pty turtle
_sha256 fractions ptyprocess types
_sha512 ftplib pwd unicodedata
_socket functools py_compile unittest
_sqlite3 future_builtins pyasn1 urllib
_sre gc pyasn1_modules urllib2
_ssl genericpath pyclbr urllib3
_strptime getopt pydoc urlparse
_struct getpass pydoc_data user
_symtable gettext pyexpat uu
如您所见,列出了cv和cv2。然后我尝试了:
>>> from cv2 import *
我也试过了:
>>> import cv2
两者似乎都正确导入了模块。
然而,几个小时后我再次尝试导入cv2,但是找不到它,所以我再次运行模块检查并获得:
help> modules
Please wait a moment while I gather a list of all available modules...
/usr/local/lib/python2.7/dist-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.
"You should import from ipykernel or jupyter_client instead.", ShimWarning)
BaseHTTPServer base64 jinja2 sets
Bastion bdb json setuptools
CDROM binascii jsonschema sgmllib
CGIHTTPServer binhex jupyter sha
Canvas bisect jupyter_client shelve
ConfigParser bsddb jupyter_console shlex
Cookie bz2 jupyter_core shutil
DLFCN cPickle keyword signal
Dialog cProfile lib2to3 simplegeneric
DocXMLRPCServer cStringIO linecache singledispatch
FileDialog calendar linuxaudiodev singledispatch_helpers
FixTk certifi locale site
HTMLParser cgi logging sitecustomize
IN cgitb macpath six
IPython chardet macurl2path smtpd
MimeWriter chunk mailbox smtplib
Queue cmath mailcap sndhdr
ScrolledText cmd markupbase socket
SimpleDialog code markupsafe spwd
SimpleHTTPServer codecs marshal sqlite3
SimpleXMLRPCServer codeop math sre
SocketServer collections md5 sre_compile
StringIO colorama meld3 sre_constants
TYPES colorsys mercurial sre_parse
Tix commands mhlib ssl
Tkconstants compileall mimetools stat
Tkdnd compiler mimetypes statvfs
Tkinter contextlib mimify storemagic
UserDict cookielib mistune string
UserList copy mmap stringold
UserString copy_reg modulefinder stringprep
_LWPCookieJar crcmod multifile strop
_MozillaCookieJar crypt multiprocessing struct
__builtin__ csv mutex subprocess
__future__ ctypes nbconvert sunau
_abcoll curses nbformat sunaudio
_ast cythonmagic netrc supervisor
_bisect datetime new symbol
_bsddb dbhash nis sympyprinting
_codecs dbm nntplib symtable
_codecs_cn debconf notebook sys
_codecs_hk decimal ntpath sysconfig
_codecs_iso2022 decorator nturl2path syslog
_codecs_jp difflib numbers tabnanny
_codecs_kr dircache oauth2client tarfile
_codecs_tw dis opcode telnetlib
_collections distlib operator tempfile
_csv distutils optparse terminado
_ctypes doctest os termios
_ctypes_test dumbdbm os2emxpath test
_curses dummy_thread ossaudiodev test_path
_curses_panel dummy_threading parser tests
_elementtree easy_install path textwrap
_functools email pdb this
_hashlib encodings pexpect thread
_heapq ensurepip pickle threading
_hotshot errno pickleshare time
_io exceptions pickletools timeit
_json fcntl pip tkColorChooser
_locale filecmp pipes tkCommonDialog
_lsprof fileinput pkg_resources tkFileDialog
_markerlib fnmatch pkgutil tkFont
_md5 formatter platform tkMessageBox
_multibytecodec fpectl plistlib tkSimpleDialog
_multiprocessing fpformat popen2 toaiff
_osx_support fractions poplib token
_pyio ftplib posix tokenize
_random functools posixfile tornado
_sha functools32 posixpath trace
_sha256 future_builtins pprint traceback
_sha512 gc profile traitlets
_socket genericpath pstats ttk
_sqlite3 getopt pty tty
_sre getpass ptyprocess turtle
_ssl gettext pwd types
_strptime glob py_compile unicodedata
Canvas bisect jupyter_client shelve
_struct grp pyasn1 unittest
_symtable gzip pyasn1_modules urllib
_sysconfigdata hashlib pyclbr urllib2
_sysconfigdata_nd heapq pydoc urllib3
_testcapi hgext pydoc_data urlparse
_threading_local hmac pyexpat user
_warnings hotshot pygments uu
_weakref html5lib qtconsole uuid
_weakrefset htmlentitydefs quopri warnings
abc htmllib random wave
aifc httplib re weakref
antigravity httplib2 readline webbrowser
anydbm ihooks repr whichdb
argparse imaplib requests wsgiref
array imghdr resource xdrlib
ast imp rexec xml
asynchat importlib rfc822 xmllib
asyncore imputil rlcompleter xmlrpclib
atexit inspect rmagic xxsubtype
audiodev io robotparser zipfile
audioop ipykernel rsa zipimport
autoreload ipython_genutils runpy zlib
backports ipywidgets sched zmq
backports_abc itertools select
我的openCV安装发生了什么变化?
如果有人知道如何正确安装openCV并将其导入我的python脚本的完整文档帮助,请发布该链接!我从Google云端文档here和here了解到,我应该能够在我的虚拟机上使用openCV。
有关如何设置Dockerfile和requirements.txt文件以正确使用openCV的更详细说明也会很有帮助。同样,这在上面链接的Google Cloud文档中引用,但从未详细解释过。
谢谢!
答案 0 :(得分:1)
Google Cloud Shell只是运行virtual machine的Google Cloud SDK。这是运行gcloud命令以与Google Cloud Project资源进行交互和管理的快速方法。但它不包含您的实际项目资源。
Cloud Shell的会话仅在处于活动状态时保持不变,并在一小时不活动后终止。因此,在Cloud Shell虚拟机上导入openCV与您的项目完全不同,并且不会以任何方式持久保存。
要将openCV应用程序部署到App Engine,您需要在openCV应用程序的目录中使用“gcloud app deploy”命令。
作为openCV的替代方案,我们现在提供Machine Learning products,使您的应用程序能够分析图像,视频,语音,文本等。