OSError: [Errno 48] Адрес уже используется в anki vector SDK (vectorCloud) - PullRequest
0 голосов
/ 29 февраля 2020

Я действительно новичок ie в кодировании. Я использую MacOS Mojave. Я пытаюсь использовать робот Anki Vector SDK и используя код rmountjoy92 / VectorCloud. сначала мне удается открыть приложение, основанное на веб flask. проблема возникает, когда я не могу закрыть свой IDLE, потому что почему-то я не могу использовать кнопку control + C, чтобы остановить его. поэтому я просто использую кнопку закрытия в IDLE (с красной и х меткой) теперь, когда я пытаюсь открыть код заново, всегда отображается ошибка, подобная этой:

Traceback (most recent call last):
  File "/Users/Rasyid/Library/Python/3.8/lib/python/site-packages/flask/app.py", line 990, in run
    run_simple(host, port, self, **options)
  File "/Users/Rasyid/Library/Python/3.8/lib/python/site-packages/werkzeug/serving.py", line 1030, in run_simple
    s.bind(server_address)
OSError: [Errno 48] Address already in use

я уже прочитал и попробую из этого one OSError: [Errno 48] Адрес уже используется

, но это не поможет, потому что я новичок ie.

код app.py Строка 990 похожа на эту

 @debug.setter
    def debug(self, value):
        self.config["DEBUG"] = value
        self.jinja_env.auto_reload = self.templates_auto_reload

def run(self, host=None, port=None, debug=None, load_dotenv=True, **options):
    """Runs the application on a local development server.

    Do not use ``run()`` in a production setting. It is not intended to
    meet security and performance requirements for a production server.
    Instead, see :ref:`deployment` for WSGI server recommendations.

    If the :attr:`debug` flag is set the server will automatically reload
    for code changes and show a debugger in case an exception happened.

    If you want to run the application in debug mode, but disable the
    code execution on the interactive debugger, you can pass
    ``use_evalex=False`` as parameter.  This will keep the debugger's
    traceback screen active, but disable code execution.

    It is not recommended to use this function for development with
    automatic reloading as this is badly supported.  Instead you should
    be using the :command:`flask` command line script's ``run`` support.

    .. admonition:: Keep in Mind

       Flask will suppress any server error with a generic error page
       unless it is in debug mode.  As such to enable just the
       interactive debugger without the code reloading, you have to
       invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
       Setting ``use_debugger`` to ``True`` without being in debug mode
       won't catch any exceptions because there won't be any to
       catch.

    :param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
        have the server available externally as well. Defaults to
        ``'127.0.0.1'`` or the host in the ``SERVER_NAME`` config variable
        if present.
    :param port: the port of the webserver. Defaults to ``5000`` or the
        port defined in the ``SERVER_NAME`` config variable if present.
    :param debug: if given, enable or disable debug mode. See
        :attr:`debug`.
    :param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
        files to set environment variables. Will also change the working
        directory to the directory containing the first file found.
    :param options: the options to be forwarded to the underlying Werkzeug
        server. See :func:`werkzeug.serving.run_simple` for more
        information.

    .. versionchanged:: 1.0
        If installed, python-dotenv will be used to load environment
        variables from :file:`.env` and :file:`.flaskenv` files.

        If set, the :envvar:`FLASK_ENV` and :envvar:`FLASK_DEBUG`
        environment variables will override :attr:`env` and
        :attr:`debug`.

        Threaded mode is enabled by default.

    .. versionchanged:: 0.10
        The default port is now picked from the ``SERVER_NAME``
        variable.
    """
    # Change this into a no-op if the server is invoked from the
    # command line. Have a look at cli.py for more information.
    if os.environ.get("FLASK_RUN_FROM_CLI") == "true":
        from .debughelpers import explain_ignored_app_run

        explain_ignored_app_run()
        return

    if get_load_dotenv(load_dotenv):
        cli.load_dotenv()

        # if set, let env vars override previous values
        if "FLASK_ENV" in os.environ:
            self.env = get_env()
            self.debug = get_debug_flag()
        elif "FLASK_DEBUG" in os.environ:
            self.debug = get_debug_flag()

    # debug passed to method overrides all other sources
    if debug is not None:
        self.debug = bool(debug)

    _host = "127.0.0.1"
    _port = 5000
    server_name = self.config.get("SERVER_NAME")
    sn_host, sn_port = None, None

    if server_name:
        sn_host, _, sn_port = server_name.partition(":")

    host = host or sn_host or _host
    # pick the first value that's not None (0 is allowed)
    port = int(next((p for p in (port, sn_port) if p is not None), _port))

    options.setdefault("use_reloader", self.debug)
    options.setdefault("use_debugger", self.debug)
    options.setdefault("threaded", True)

    cli.show_server_banner(self.env, self.debug, self.name, False)

    from werkzeug.serving import run_simple

    try:
        run_simple(host, port, self, **options)        **<< this one is line 990**
    finally:
        # reset the first request information if the development server
        # reset normally.  This makes it possible to restart the server
        # without reloader and that stuff from an interactive shell.
        self._got_first_request = False

, а строка обслуживания.py 1030 похожа на эту

  def inner():
        try:
            fd = int(os.environ["WERKZEUG_SERVER_FD"])
        except (LookupError, ValueError):
            fd = None
        srv = make_server(
            hostname,
            port,
            application,
            threaded,
            processes,
            request_handler,
            passthrough_errors,
            ssl_context,
            fd=fd,
        )
        if fd is None:
            log_startup(srv.socket)
        srv.serve_forever()

if use_reloader:
    # If we're not running already in the subprocess that is the
    # reloader we want to open up a socket early to make sure the
    # port is actually available.
    if not is_running_from_reloader():
        if port == 0 and not can_open_by_fd:
            raise ValueError(
                "Cannot bind to a random port with enabled "
                "reloader if the Python interpreter does "
                "not support socket opening by fd."
            )

        # Create and destroy a socket so that any exceptions are
        # raised before we spawn a separate Python interpreter and
        # lose this ability.
        address_family = select_address_family(hostname, port)
        server_address = get_sockaddr(hostname, port, address_family)
        s = socket.socket(address_family, socket.SOCK_STREAM)
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        s.bind(server_address)          **<<<  this one is line 1030**
        if hasattr(s, "set_inheritable"):
            s.set_inheritable(True)

        # If we can open the socket by file descriptor, then we can just
        # reuse this one and our socket will survive the restarts.
        if can_open_by_fd:
            os.environ["WERKZEUG_SERVER_FD"] = str(s.fileno())
            s.listen(LISTEN_QUEUE)
            log_startup(s)
        else:
            s.close()
            if address_family == af_unix:
                _log("info", "Unlinking %s" % server_address)
                os.unlink(server_address)

    # Do not use relative imports, otherwise "python -m werkzeug.serving"
    # breaks.
    from ._reloader import run_with_reloader

    run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
else:
    inner()

Может ли кто-нибудь помочь мне с понятным словом? пожалуйста, скажите мне, если я ошибаюсь в своем сообщении здесь, это мой первый пост. спасибо

...