星瞳实验室APP,快速收到回复
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 请问 神经网络中示例代码里面



    • 有导入os模块,其中os模块里面导入了一个abc模块,python提示没有这abc个模块...网上也搜索不到这个模块的信息,去掉就运行不起来...看视频里面没有出现这个问题...或者说能不能提供一下abc.py的源码或者功能....请求帮助 \大哭



    • 如果涉及代码,需要报错提示与全部代码文本,请注意不要贴代码图片



    • r"""OS routines for NT or Posix depending on what system we're on.
      
      This exports:
        - all functions from posix or nt, e.g. unlink, stat, etc.
        - os.path is either posixpath or ntpath
        - os.name is either 'posix' or 'nt'
        - os.curdir is a string representing the current directory (always '.')
        - os.pardir is a string representing the parent directory (always '..')
        - os.sep is the (or a most common) pathname separator ('/' or '\\')
        - os.extsep is the extension separator (always '.')
        - os.altsep is the alternate pathname separator (None or '/')
        - os.pathsep is the component separator used in $PATH etc
        - os.linesep is the line separator in text files ('\r' or '\n' or '\r\n')
        - os.defpath is the default search path for executables
        - os.devnull is the file path of the null device ('/dev/null', etc.)
      
      Programs that import and use 'os' stand a better chance of being
      portable between different platforms.  Of course, they must then
      only use functions that are defined by all platforms (e.g., unlink
      and opendir), and leave all pathname manipulation to os.path
      (e.g., split and join).
      """
      
      #'
      import abc
      import sys
      import stat as st
      
      _names = sys.builtin_module_names
      
      # Note:  more names are added to __all__ later.
      __all__ = ["altsep", "curdir", "pardir", "sep", "pathsep", "linesep",
                 "defpath", "name", "path", "devnull", "SEEK_SET", "SEEK_CUR",
                 "SEEK_END", "fsencode", "fsdecode", "get_exec_path", "fdopen",
                 "popen", "extsep"]
      
      def _exists(name):
          return name in globals()
      
      def _get_exports_list(module):
          try:
              return list(module.__all__)
          except AttributeError:
              return [n for n in dir(module) if n[0] != '_']
      
      # Any new dependencies of the os module and/or changes in path separator
      # requires updating importlib as well.
      if 'posix' in _names:
          name = 'posix'
          linesep = '\n'
          from posix import *
          try:
              from posix import _exit
              __all__.append('_exit')
          except ImportError:
              pass
          import posixpath as path
      
          try:
              from posix import _have_functions
          except ImportError:
              pass
      
          import posix
          __all__.extend(_get_exports_list(posix))
          del posix
      
      elif 'nt' in _names:
          name = 'nt'
          linesep = '\r\n'
          from nt import *
          try:
              from nt import _exit
              __all__.append('_exit')
          except ImportError:
              pass
          import ntpath as path
      
          import nt
          __all__.extend(_get_exports_list(nt))
          del nt
      
          try:
              from nt import _have_functions
          except ImportError:
              pass
      
      else:
          raise ImportError('no os specific module found')
      
      sys.modules['os.path'] = path
      from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,
          devnull)
      
      del _names
      
      
      if _exists("_have_functions"):
          _globals = globals()
          def _add(str, fn):
              if (fn in _globals) and (str in _have_functions):
                  _set.add(_globals[fn])
      
          _set = set()
          _add("HAVE_FACCESSAT",  "access")
          _add("HAVE_FCHMODAT",   "chmod")
          _add("HAVE_FCHOWNAT",   "chown")
          _add("HAVE_FSTATAT",    "stat")
          _add("HAVE_FUTIMESAT",  "utime")
          _add("HAVE_LINKAT",     "link")
          _add("HAVE_MKDIRAT",    "mkdir")
          _add("HAVE_MKFIFOAT",   "mkfifo")
          _add("HAVE_MKNODAT",    "mknod")
          _add("HAVE_OPENAT",     "open")
          _add("HAVE_READLINKAT", "readlink")
          _add("HAVE_RENAMEAT",   "rename")
          _add("HAVE_SYMLINKAT",  "symlink")
          _add("HAVE_UNLINKAT",   "unlink")
          _add("HAVE_UNLINKAT",   "rmdir")
          _add("HAVE_UTIMENSAT",  "utime")
          supports_dir_fd = _set
      
          _set = set()
          _add("HAVE_FACCESSAT",  "access")
          supports_effective_ids = _set
      
          _set = set()
          _add("HAVE_FCHDIR",     "chdir")
          _add("HAVE_FCHMOD",     "chmod")
          _add("HAVE_FCHOWN",     "chown")
          _add("HAVE_FDOPENDIR",  "listdir")
          _add("HAVE_FDOPENDIR",  "scandir")
          _add("HAVE_FEXECVE",    "execve")
          _set.add(stat) # fstat always works
          _add("HAVE_FTRUNCATE",  "truncate")
          _add("HAVE_FUTIMENS",   "utime")
          _add("HAVE_FUTIMES",    "utime")
          _add("HAVE_FPATHCONF",  "pathconf")
          if _exists("statvfs") and _exists("fstatvfs"): # mac os x10.3
              _add("HAVE_FSTATVFS", "statvfs")
          supports_fd = _set
      
          _set = set()
          _add("HAVE_FACCESSAT",  "access")
          # Some platforms don't support lchmod().  Often the function exists
          # anyway, as a stub that always returns ENOSUP or perhaps EOPNOTSUPP.
          # (No, I don't know why that's a good design.)  ./configure will detect
          # this and reject it--so HAVE_LCHMOD still won't be defined on such
          # platforms.  This is Very Helpful.
          #
          # However, sometimes platforms without a working lchmod() *do* have
          # fchmodat().  (Examples: Linux kernel 3.2 with glibc 2.15,
          # OpenIndiana 3.x.)  And fchmodat() has a flag that theoretically makes
          # it behave like lchmod().  So in theory it would be a suitable
          # replacement for lchmod().  But when lchmod() doesn't work, fchmodat()'s
          # flag doesn't work *either*.  Sadly ./configure isn't sophisticated
          # enough to detect this condition--it only determines whether or not
          # fchmodat() minimally works.
          #
          # Therefore we simply ignore fchmodat() when deciding whether or not
          # os.chmod supports follow_symlinks.  Just checking lchmod() is
          # sufficient.  After all--if you have a working fchmodat(), your
          # lchmod() almost certainly works too.
          #
          # _add("HAVE_FCHMODAT",   "chmod")
          _add("HAVE_FCHOWNAT",   "chown")
          _add("HAVE_FSTATAT",    "stat")
          _add("HAVE_LCHFLAGS",   "chflags")
          _add("HAVE_LCHMOD",     "chmod")
          if _exists("lchown"): # mac os x10.3
              _add("HAVE_LCHOWN", "chown")
          _add("HAVE_LINKAT",     "link")
          _add("HAVE_LUTIMES",    "utime")
          _add("HAVE_LSTAT",      "stat")
          _add("HAVE_FSTATAT",    "stat")
          _add("HAVE_UTIMENSAT",  "utime")
          _add("MS_WINDOWS",      "stat")
          supports_follow_symlinks = _set
      
          del _set
          del _have_functions
          del _globals
          del _add
      
      
      # Python uses fixed values for the SEEK_ constants; they are mapped
      # to native constants if necessary in posixmodule.c
      # Other possible SEEK values are directly imported from posixmodule.c
      SEEK_SET = 0
      SEEK_CUR = 1
      SEEK_END = 2
      
      # Super directory utilities.
      # (Inspired by Eric Raymond; the doc strings are mostly his)
      
      def makedirs(name, mode=0o777, exist_ok=False):
          """makedirs(name [, mode=0o777][, exist_ok=False])
      
          Super-mkdir; create a leaf directory and all intermediate ones.  Works like
          mkdir, except that any intermediate path segment (not just the rightmost)
          will be created if it does not exist. If the target directory already
          exists, raise an OSError if exist_ok is False. Otherwise no exception is
          raised.  This is recursive.
      
          """
          head, tail = path.split(name)
          if not tail:
              head, tail = path.split(head)
          if head and tail and not path.exists(head):
              try:
                  makedirs(head, exist_ok=exist_ok)
              except FileExistsError:
                  # Defeats race condition when another thread created the path
                  pass
              cdir = curdir
              if isinstance(tail, bytes):
                  cdir = bytes(curdir, 'ASCII')
              if tail == cdir:           # xxx/newdir/. exists if xxx/newdir exists
                  return
          try:
              mkdir(name, mode)
          except OSError:
              # Cannot rely on checking for EEXIST, since the operating system
              # could give priority to other errors like EACCES or EROFS
              if not exist_ok or not path.isdir(name):
                  raise
      
      def removedirs(name):
          """removedirs(name)
      
          Super-rmdir; remove a leaf directory and all empty intermediate
          ones.  Works like rmdir except that, if the leaf directory is
          successfully removed, directories corresponding to rightmost path
          segments will be pruned away until either the whole path is
          consumed or an error occurs.  Errors during this latter phase are
          ignored -- they generally mean that a directory was not empty.
      
          """
          rmdir(name)
          head, tail = path.split(name)
          if not tail:
              head, tail = path.split(head)
          while head and tail:
              try:
                  rmdir(head)
              except OSError:
                  break
              head, tail = path.split(head)
      
      def renames(old, new):
          """renames(old, new)
      
          Super-rename; create directories as necessary and delete any left
          empty.  Works like rename, except creation of any intermediate
          directories needed to make the new pathname good is attempted
          first.  After the rename, directories corresponding to rightmost
          path segments of the old name will be pruned until either the
          whole path is consumed or a nonempty directory is found.
      
          Note: this function can fail with the new directory structure made
          if you lack permissions needed to unlink the leaf directory or
          file.
      
          """
          head, tail = path.split(new)
          if head and tail and not path.exists(head):
              makedirs(head)
          rename(old, new)
          head, tail = path.split(old)
          if head and tail:
              try:
                  removedirs(head)
              except OSError:
                  pass
      
      __all__.extend(["makedirs", "removedirs", "renames"])
      
      def walk(top, topdown=True, onerror=None, followlinks=False):
          """Directory tree generator.
      
          For each directory in the directory tree rooted at top (including top
          itself, but excluding '.' and '..'), yields a 3-tuple
      
              dirpath, dirnames, filenames
      
          dirpath is a string, the path to the directory.  dirnames is a list of
          the names of the subdirectories in dirpath (excluding '.' and '..').
          filenames is a list of the names of the non-directory files in dirpath.
          Note that the names in the lists are just names, with no path components.
          To get a full path (which begins with top) to a file or directory in
          dirpath, do os.path.join(dirpath, name).
      
          If optional arg 'topdown' is true or not specified, the triple for a
          directory is generated before the triples for any of its subdirectories
          (directories are generated top down).  If topdown is false, the triple
          for a directory is generated after the triples for all of its
          subdirectories (directories are generated bottom up).
      
          When topdown is true, the caller can modify the dirnames list in-place
          (e.g., via del or slice assignment), and walk will only recurse into the
          subdirectories whose names remain in dirnames; this can be used to prune the
          search, or to impose a specific order of visiting.  Modifying dirnames when
          topdown is false is ineffective, since the directories in dirnames have
          already been generated by the time dirnames itself is generated. No matter
          the value of topdown, the list of subdirectories is retrieved before the
          tuples for the directory and its subdirectories are generated.
      
          By default errors from the os.scandir() call are ignored.  If
          optional arg 'onerror' is specified, it should be a function; it
          will be called with one argument, an OSError instance.  It can
          report the error to continue with the walk, or raise the exception
          to abort the walk.  Note that the filename is available as the
          filename attribute of the exception object.
      
          By default, os.walk does not follow symbolic links to subdirectories on
          systems that support them.  In order to get this functionality, set the
          optional argument 'followlinks' to true.
      
          Caution:  if you pass a relative pathname for top, don't change the
          current working directory between resumptions of walk.  walk never
          changes the current directory, and assumes that the client doesn't
          either.
      
          Example:
      
          import os
          from os.path import join, getsize
          for root, dirs, files in os.walk('python/Lib/email'):
              print(root, "consumes", end="")
              print(sum([getsize(join(root, name)) for name in files]), end="")
              print("bytes in", len(files), "non-directory files")
              if 'CVS' in dirs:
                  dirs.remove('CVS')  # don't visit CVS directories
      
          """
          top = fspath(top)
          dirs = []
          nondirs = []
          walk_dirs = []
      
          # We may not have read permission for top, in which case we can't
          # get a list of the files the directory contains.  os.walk
          # always suppressed the exception then, rather than blow up for a
          # minor reason when (say) a thousand readable directories are still
          # left to visit.  That logic is copied here.
          try:
              # Note that scandir is global in this module due
              # to earlier import-*.
              scandir_it = scandir(top)
          except OSError as error:
              if onerror is not None:
                  onerror(error)
              return
      
          with scandir_it:
              while True:
                  try:
                      try:
                          entry = next(scandir_it)
                      except StopIteration:
                          break
                  except OSError as error:
                      if onerror is not None:
                          onerror(error)
                      return
      
                  try:
                      is_dir = entry.is_dir()
                  except OSError:
                      # If is_dir() raises an OSError, consider that the entry is not
                      # a directory, same behaviour than os.path.isdir().
                      is_dir = False
      
                  if is_dir:
                      dirs.append(entry.name)
                  else:
                      nondirs.append(entry.name)
      
                  if not topdown and is_dir:
                      # Bottom-up: recurse into sub-directory, but exclude symlinks to
                      # directories if followlinks is False
                      if followlinks:
                          walk_into = True
                      else:
                          try:
                              is_symlink = entry.is_symlink()
                          except OSError:
                              # If is_symlink() raises an OSError, consider that the
                              # entry is not a symbolic link, same behaviour than
                              # os.path.islink().
                              is_symlink = False
                          walk_into = not is_symlink
      
                      if walk_into:
                          walk_dirs.append(entry.path)
      
          # Yield before recursion if going top down
          if topdown:
              yield top, dirs, nondirs
      
              # Recurse into sub-directories
              islink, join = path.islink, path.join
              for dirname in dirs:
                  new_path = join(top, dirname)
                  # Issue #23605: os.path.islink() is used instead of caching
                  # entry.is_symlink() result during the loop on os.scandir() because
                  # the caller can replace the directory entry during the "yield"
                  # above.
                  if followlinks or not islink(new_path):
                      yield from walk(new_path, topdown, onerror, followlinks)
          else:
              # Recurse into sub-directories
              for new_path in walk_dirs:
                  yield from walk(new_path, topdown, onerror, followlinks)
              # Yield after recursion if going bottom up
              yield top, dirs, nondirs
      
      __all__.append("walk")
      
      if {open, stat} <= supports_dir_fd and {scandir, stat} <= supports_fd:
      
          def fwalk(top=".", topdown=True, onerror=None, *, follow_symlinks=False, dir_fd=None):
              """Directory tree generator.
      
              This behaves exactly like walk(), except that it yields a 4-tuple
      
                  dirpath, dirnames, filenames, dirfd
      
              `dirpath`, `dirnames` and `filenames` are identical to walk() output,
              and `dirfd` is a file descriptor referring to the directory `dirpath`.
      
              The advantage of fwalk() over walk() is that it's safe against symlink
              races (when follow_symlinks is False).
      
              If dir_fd is not None, it should be a file descriptor open to a directory,
                and top should be relative; top will then be relative to that directory.
                (dir_fd is always supported for fwalk.)
      
              Caution:
              Since fwalk() yields file descriptors, those are only valid until the
              next iteration step, so you should dup() them if you want to keep them
              for a longer period.
      
              Example:
      
              import os
              for root, dirs, files, rootfd in os.fwalk('python/Lib/email'):
                  print(root, "consumes", end="")
                  print(sum([os.stat(name, dir_fd=rootfd).st_size for name in files]),
                        end="")
                  print("bytes in", len(files), "non-directory files")
                  if 'CVS' in dirs:
                      dirs.remove('CVS')  # don't visit CVS directories
              """
              if not isinstance(top, int) or not hasattr(top, '__index__'):
                  top = fspath(top)
              # Note: To guard against symlink races, we use the standard
              # lstat()/open()/fstat() trick.
              if not follow_symlinks:
                  orig_st = stat(top, follow_symlinks=False, dir_fd=dir_fd)
              topfd = open(top, O_RDONLY, dir_fd=dir_fd)
              try:
                  if (follow_symlinks or (st.S_ISDIR(orig_st.st_mode) and
                                          path.samestat(orig_st, stat(topfd)))):
                      yield from _fwalk(topfd, top, isinstance(top, bytes),
                                        topdown, onerror, follow_symlinks)
              finally:
                  close(topfd)
      
          def _fwalk(topfd, toppath, isbytes, topdown, onerror, follow_symlinks):
              # Note: This uses O(depth of the directory tree) file descriptors: if
              # necessary, it can be adapted to only require O(1) FDs, see issue
              # #13734.
      
      
      


    • 0_1557412132834_T5XMWZKM{G0A@@C~XDIQSSS.png



    • @kidswong999 这个是神经网络示例里面导入的os库,显示没有abc模块



    • 这个不是OpenMV上的程序。



    • 0_1557470996407_08NBT8W_6A096SJ`6PA0G~T.png

      虽然很抱歉打扰,但是这个确实是你们的模块导入的os文件,然后再在os文件里面导入的abc文件...





    • os模块是内置在OpenMV的,不是你提供的代码。



    • @kidswong999 哦哦,谢谢....能不能给一下os文件...我从git上面下了一个,发现它用了wifi模块...



    • @mtfs 没有os文件。os是内置在OpenMV的,不需要额外添加。