Giter VIP home page Giter VIP logo

Comments (17)

Chunmi-Tommy3886 avatar Chunmi-Tommy3886 commented on August 23, 2024 5

maybe pip3 install django_socketio can solve

from django-socketio.

esarearthur avatar esarearthur commented on August 23, 2024

Cloned and installed it manually it is working fine

from django-socketio.

andriy-sa avatar andriy-sa commented on August 23, 2024

the same error(

from django-socketio.

adnanrafique avatar adnanrafique commented on August 23, 2024

Hello there support team, I got the same error while installing it. I also tried installing it manually but still nothing. I'm using django version 2.0. Please help.

from django-socketio.

nh916 avatar nh916 commented on August 23, 2024

same error

from django-socketio.

dashko avatar dashko commented on August 23, 2024

same error

from django-socketio.

dushanchen avatar dushanchen commented on August 23, 2024

same error !

from django-socketio.

dushanchen avatar dushanchen commented on August 23, 2024

python3.7 , django2.1.4,
pip3 install django_socketio and python3 setup.py install, both got this:

except IndexError, KeyError:
^
SyntaxError: invalid syntax
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

from django-socketio.

avidcoder123 avatar avidcoder123 commented on August 23, 2024

I had the same problem too, but I found that while pip install django-socketio returns an error, pip install -U django-socketio works seamlessly.

from django-socketio.

nalibjchn avatar nalibjchn commented on August 23, 2024

same issue

from django-socketio.

nalibjchn avatar nalibjchn commented on August 23, 2024

I used python 2.7, it works. you have to degrade your python version.

from django-socketio.

nh916 avatar nh916 commented on August 23, 2024

@lindalibjchn I think Python 2 is going out of style and will have less support so its not an option.

but now that we know that it works with python 2 and not 3, maybe we can just update it from python 2 to python 3 and itll work again

from django-socketio.

Muhammed-Rajab avatar Muhammed-Rajab commented on August 23, 2024

The latest version of django-socketio is released on 2014. It's seems pretty old. I think it's better to use Django Channels.

For references,
Check documentation

from django-socketio.

Muhammed-Rajab avatar Muhammed-Rajab commented on August 23, 2024

I used python 2.7, it works. you have to degrade your python version.

It's not a great idea to degrade to 2.7. It's pretty old and not recommended..

from django-socketio.

Jaykumar-Maradiya avatar Jaykumar-Maradiya commented on August 23, 2024

pip install django-socketio problem

Collecting django-socketio
Downloading django-socketio-0.3.9.tar.gz (48 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.0/48.0 kB 401.8 kB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [11 lines of output]
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "C:\Users\dell 5470\AppData\Local\Temp\pip-install-63_gzqda\django-socketio_6ddb8fd399e44adb9a9f6512d320f464\setup.py", line 7, in
version = import("django_socketio").version,
File "C:\Users\dell 5470\AppData\Local\Temp\pip-install-63_gzqda\django-socketio_6ddb8fd399e44adb9a9f6512d320f464\django_socketio_init_.py", line 2, in

from django_socketio.utils import NoSocket, send, broadcast, broadcast_channel
File "C:\Users\dell 5470\AppData\Local\Temp\pip-install-63_gzqda\django-socketio_6ddb8fd399e44adb9a9f6512d320f464\django_socketio\utils.py", line 44
except IndexError, KeyError:
^^^^^^^^^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

from django-socketio.

Jaykumar-Maradiya avatar Jaykumar-Maradiya commented on August 23, 2024

I have solutions for this installation problem

  1. Add manually in your site-packages (https://www.youtube.com/watch?v=DKR0VYSOqLc&ab_channel=ProgrammingwithMosh)

  2. If you are using python 3.10 version python 3.10 does not support some methods inside this django-socketio so replace this package .

  3. Name the file events.py Replace your code with my code
    import re
    class EventError(Exception):
    pass
    class Event(object):
    """
    Signal-like object for Socket.IO events that supports
    filtering on channels. Registering event handlers is
    performed by using the Event instance as a decorator::

     @on_message
     def message(request, socket, message):
         ...
    

    Event handlers can also be registered for particular
    channels using the channel keyword argument with a
    regular expression pattern::

     @on_message(channel="^room-")
     def message(request, socket, message):
         ...
    

    The on_connect event cannot be registered with a
    channel pattern since channel subscription occurs
    after a connection is established.
    """

    def init(self, supports_channels=True):
    self.supports_channels = supports_channels
    self.handlers = []

    def call(self, handler=None, channel=None):
    """
    Decorates the given handler. The event may be called
    with only a channel argument, in which case return a
    decorator with the channel argument bound.
    """
    if handler is None:
    def handler_with_channel(handler):
    return self.call(handler, channel)

         return handler_with_channel
     if channel:
         if not self.supports_channels:
             raise EventError("The %s event does not support channels so "
                              "the handler `%s` could not be registered" %
                              (self.name, handler.__name__))
         channel = re.compile(channel)
     self.handlers.append((handler, channel))
    

    def send(self, request, socket, context, *args):
    """
    When an event is sent, run all relevant handlers. Relevant
    handlers are those without a channel pattern when the given
    socket is not subscribed to any particular channel, or the
    handlers with a channel pattern that matches any of the
    channels that the given socket is subscribed to.

     In the case of subscribe/unsubscribe, match the channel arg
     being sent to the channel pattern.
     """
     for handler, pattern in self.handlers:
         no_channel = not pattern and not socket.channels
         if self.name.endswith("subscribe") and pattern:
             matches = [pattern.match(args[0])]
         else:
             matches = [pattern.match(c) for c in socket.channels if pattern]
         if no_channel or any(filter(None, matches)):
             handler(request, socket, context, *args)
    

Define a list to hold Event instances

event_instances = []

on_connect = Event(False)
on_message = Event()
on_subscribe = Event()
on_unsubscribe = Event()
on_error = Event()
on_disconnect = Event()
on_finish = Event()

Add the Event instances to the list

event_instances.extend([
on_connect,
on_message,
on_subscribe,
on_unsubscribe,
on_error,
on_disconnect,
on_finish
])

Set the "name" attribute for each Event instance

for event_instance in event_instances:
setattr(event_instance, "name", event_instance)

Now you can continue using the Event instances as before

  1. Name the file utils.py Replace your code with my code
    except (IndexError, KeyError):

I hope django-scoketio will work after all these changes

from django-socketio.

Jaykumar-Maradiya avatar Jaykumar-Maradiya commented on August 23, 2024

events.py file


**import re


class EventError(Exception):
    pass


class Event(object):
    """
    Signal-like object for Socket.IO events that supports
    filtering on channels. Registering event handlers is
    performed by using the Event instance as a decorator::

        @on_message
        def message(request, socket, message):
            ...

    Event handlers can also be registered for particular
    channels using the channel keyword argument with a
    regular expression pattern::

        @on_message(channel="^room-")
        def message(request, socket, message):
            ...

    The ``on_connect`` event cannot be registered with a
    channel pattern since channel subscription occurs
    after a connection is established.
    """

    def __init__(self, supports_channels=True):
        self.supports_channels = supports_channels
        self.handlers = []

    def __call__(self, handler=None, channel=None):
        """
        Decorates the given handler. The event may be called
        with only a channel argument, in which case return a
        decorator with the channel argument bound.
        """
        if handler is None:
            def handler_with_channel(handler):
                return self.__call__(handler, channel)

            return handler_with_channel
        if channel:
            if not self.supports_channels:
                raise EventError("The %s event does not support channels so "
                                 "the handler `%s` could not be registered" %
                                 (self.name, handler.__name__))
            channel = re.compile(channel)
        self.handlers.append((handler, channel))

    def send(self, request, socket, context, *args):
        """
        When an event is sent, run all relevant handlers. Relevant
        handlers are those without a channel pattern when the given
        socket is not subscribed to any particular channel, or the
        handlers with a channel pattern that matches any of the
        channels that the given socket is subscribed to.

        In the case of subscribe/unsubscribe, match the channel arg
        being sent to the channel pattern.
        """
        for handler, pattern in self.handlers:
            no_channel = not pattern and not socket.channels
            if self.name.endswith("subscribe") and pattern:
                matches = [pattern.match(args[0])]
            else:
                matches = [pattern.match(c) for c in socket.channels if pattern]
            if no_channel or any(filter(None, matches)):
                handler(request, socket, context, *args)


# Define a list to hold Event instances
event_instances = []

on_connect = Event(False)
on_message = Event()
on_subscribe = Event()
on_unsubscribe = Event()
on_error = Event()
on_disconnect = Event()
on_finish = Event()

# Add the Event instances to the list
event_instances.extend([
    on_connect,
    on_message,
    on_subscribe,
    on_unsubscribe,
    on_error,
    on_disconnect,
    on_finish
])

# Set the "name" attribute for each Event instance
for event_instance in event_instances:
    setattr(event_instance, "name", event_instance)

# Now you can continue using the Event instances as before**

utils.py

except (IndexError, KeyError):

from django-socketio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.