简体   繁体   中英

flask socket io not working ( windows 7 & 10 ) anaconda and python 3.7

I'm still a newbie in Development ( please don't rate down my post i've reached out everywhere to find a solution for the past 5 days ) , I had only two projects as a tutorial in the second project i had to use Socket IO with flask but its not working - if my code doesnt have socket io in it and i ran flask run it output the following :

D:\WORK\study sc5\project1\project1>flask run
Serving Flask app "hello"
Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

if it has socket io in it :

D:\WORK\study sc5\project2\project2>flask run
 * Serving Flask-SocketIO app "application"

**when i visited 127.0.0.1:5000 i found the server running so i ignored that it doesn't print Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) and kept going tell i made the first test to see if socket io can print and i have noticed everything prints just fine but socket io

I've asked my class mates , made ticket on github for 5 days we couldn't solve this and i have tried on 2 machines ( home windows 10 and work place windows 7 ) both resulting the same thing

i made 2 videos about it ( i'll try to share them here if i'm allowed )

the .py files only have the following

import os

from flask import Flask
from flask_socketio import SocketIO, emit

app = Flask(__name__)
app.config["SECRET_KEY"] = "sdfsdfssefe"
socketio = SocketIO(app)


@app.route("/")
def index():
    return "Project 2: TODO"

systems i have this with 1- windows 10 - anacanda 2- windows 7 - anacanda

things i have tried so far :

  • updating anaconda
  • eventlet
  • gevent
  • uninstalling anaconda
  • reinstalling a newer version of anaconda
  • uninstalling anaconda again
  • installing python 3.7
  • installing all required to run project 1
    import os , passlib,requests

    from flask import Flask, session , render_template , request from

    flask_session import Session from sqlalchemy import create_engine

    from sqlalchemy.orm import scoped_session, sessionmaker from

    passlib.hash import sha256_crypt

  • instaling eventlet with python 3.7

  • installing cgywin
  • testing server on cgywin

results all the same except

now after cgywin and python 3.7 when i tried to run my own version of project 2 which used to run smoothly but doesn't print anything from socket io - it now says ( can't import application.py )

pip freeze

  • certifi==2018.8.24
  • chardet==3.0.4
  • Click==7.0
  • dnspython==1.15.0
  • eventlet==0.24.1
  • Flask==1.0.2
  • Flask-Session==0.3.1
  • Flask-SocketIO==3.0.2
  • greenlet==0.4.15
  • idna==2.7
  • itsdangerous==0.24
  • Jinja2==2.10
  • MarkupSafe==1.0
  • monotonic==1.5
  • passlib==1.7.1
  • psycopg2==2.7.5
  • python-engineio==2.3.1
  • python-socketio==2.0.0
  • requests==2.19.1
  • six==1.11.0
  • SQLAlchemy==1.2.12
  • urllib3==1.23
  • virtualenv==16.0.0
  • virtualenv-api==2.1.16
  • Werkzeug==0.14.1

I've open ticket on course group , github and videos to demonstrate what happens if anyone could explain how i can upload them i will do edit the post and share them

https://github.com/miguelgrinberg/Flask-SocketIO/issues/807 ( i've also posted videos in the latest comments )

Does this work better?

import os

from flask import Flask
from flask_socketio import SocketIO, emit

@app.route("/")
def index():
    return "Project 2: TODO"

app = Flask(__name__)
app.config["SECRET_KEY"] = "sdfsdfssefe"
socketio = SocketIO(app)

if __name__ == '__main__':
    socketio.run(app)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM