django-socketio
django-socketio copied to clipboard
Error installing
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 "
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\esare\AppData\Local\Temp\pip-build-qa39znes\django-socketio\
Cloned and installed it manually it is working fine
the same error(
maybe pip3 install django_socketio can solve
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.
same error
same error
same error !
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.
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.
same issue
I used python 2.7, it works. you have to degrade your python version.
@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
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
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..
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 "
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.
I have solutions for this installation problem
-
Add manually in your site-packages (
https://www.youtube.com/watch?v=DKR0VYSOqLc&ab_channel=ProgrammingwithMosh
) -
If you are using python 3.10 version python 3.10 does not support some methods inside this django-socketio so replace this package .
-
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
- Name the file utils.py Replace your code with my code except (IndexError, KeyError):
I hope django-scoketio will work after all these changes
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):