4

Я использовал Google App Engine с Python для размещения некоторых скриптов и хранения данных в хранилище данных, и мне нужно использовать openCV для более продвинутых манипуляций с мультимедиа.Google Cloud VM - Установка openCV

Я пытаюсь перейти на платформу Виртуальной виртуальной машины Google, и у меня возникли проблемы с пониманием того, как установить openCV.

Ранее сегодня на VM Cloud Shell Я пробовал:

sudo apt-get install python-opencv 

, который, казалось, работали, и после листинга мои питон модули я получил:

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 

Как вы можете видеть, резюме и 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 Cloud here и here, что я должен иметь возможность использовать openCV на своей виртуальной машине.

Также было бы полезно получить более подробные инструкции по настройке файлов Dockerfile и файлов требований.txt для правильного использования openCV. Опять же, об этом говорится в приведенной выше документации Google Cloud, но никогда не объяснялось подробно.

Спасибо!

ответ

1

Google Cloud Shell является просто virtual machine который запустил Google Cloud SDK. Это быстрый способ запускать команды gcloud для взаимодействия с ресурсами Google Cloud Project и управления ими. Тем не менее, он не содержит ваши фактические ресурсы проекта.

Сессия облачной оболочки сохраняется только тогда, когда она активна, и заканчивается через час бездействия. Таким образом, импорт openCV на виртуальной машине Cloud Shell полностью отделен от вашего проекта и никоим образом не сохраняется.

Чтобы развернуть приложение openCV в App Engine, вам необходимо использовать команду «gcloud app deploy» в каталоге вашего приложения openCV.

В качестве альтернативы openCV мы предлагаем Machine Learning products, который предоставляет возможность для вашего приложения анализировать изображения, видео, речь, текст и многое другое.

+0

Не сохраняется ли он, если он установлен в домашнем каталоге? – Lcat

+1

Да, если вы используете каталог [$ HOME] (https://cloud.google.com/shell/docs/features#persistent_disk_storage), он будет сохраняться между сеансами. Хотя, если вы не получаете доступ к Cloud Shell регулярно, постоянное хранилище каталога HOME может быть переработано в соответствии с документацией. – Jordan

+0

@ Jordan Какое время это точно, когда вы упоминаете «регулярно», ничего не сказано о точном временном интервале того, что регулярно означает в документации – Santhosh

Смежные вопросы