Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error installing #111

Open
esarearthur opened this issue Jun 30, 2017 · 17 comments
Open

Error installing #111

esarearthur opened this issue Jun 30, 2017 · 17 comments

Comments

@esarearthur
Copy link

I keep getting this error when I install.

Collecting django-socketio==0.3.9
Using cached django-socketio-0.3.9.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\esare\AppData\Local\Temp\pip-build-qa39znes\django-socketio\setup.py", line 7, in
version = import("django_socketio").version,
File "C:\Users\esare\AppData\Local\Temp\pip-build-qa39znes\django-socketio\django_socketio_init_.py", line 2, in
from django_socketio.utils import NoSocket, send, broadcast, broadcast_channel
File "C:\Users\esare\AppData\Local\Temp\pip-build-qa39znes\django-socketio\django_socketio\utils.py", line 44
except IndexError, KeyError:
^
SyntaxError: invalid syntax

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in C:\Users\esare\AppData\Local\Temp\pip-build-qa39znes\django-socketio\

@esarearthur
Copy link
Author

Cloned and installed it manually it is working fine

@andriy-sa
Copy link

the same error(

@Chunmi-Tommy3886
Copy link

maybe pip3 install django_socketio can solve

@adnanrafique
Copy link

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.

@nh916
Copy link

nh916 commented May 19, 2019

same error

1 similar comment
@dashko
Copy link

dashko commented Mar 24, 2020

same error

@dushanchen
Copy link

same error !

@dushanchen
Copy link

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.

@avidcoder123
Copy link

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.

@nalibjchn
Copy link

same issue

@nalibjchn
Copy link

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

@nh916
Copy link

nh916 commented Oct 22, 2020

@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

@Muhammed-Rajab
Copy link

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

@Muhammed-Rajab
Copy link

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..

@Jaykumar-Maradiya
Copy link

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.

@Jaykumar-Maradiya
Copy link

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

@Jaykumar-Maradiya
Copy link

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):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests