Comments (17)
maybe pip3 install django_socketio can solve
from django-socketio.
Cloned and installed it manually it is working fine
from django-socketio.
the same error(
from django-socketio.
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.
same error
from django-socketio.
same error
from django-socketio.
same error !
from django-socketio.
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.
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.
same issue
from django-socketio.
I used python 2.7, it works. you have to degrade your python version.
from django-socketio.
@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.
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.
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.
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.
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
from django-socketio.
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)
- manage.py runserver_socketio: error: unrecognized arguments HOT 3
- I don't want to django-socketio to reload itself
- No JSON object could be decoded HOT 1
- From socketio 0.6 to socketio 0.9 HOT 1
- Django 1.10 support HOT 3
- upgrading pip installed version HOT 2
- Clarity about
- why i use """runserver_socketio 0.0.0.0:9443""" the django web is running? HOT 3
- AttributeError: 'FlashPolicyServer' object has no attribute 'kill' HOT 1
- python3 Compatibility issues HOT 3
- Django Socketio
- Python 3 support HOT 1
- I have a trouble with installation HOT 1
- Django 2.0 support HOT 1
- Would this be compatible with Django 3? HOT 8
- Error When Running SocketIO Server HOT 1
- getting error while installing this package
- Long running thread HOT 1
- Sockets not sending data in realtime HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-socketio.