TaplierShiru / FastAPI-and-Socket-io-SimpleChat

Simple chat web page using FastAPI and python-socket-io frameworks
1 stars 1 forks source link

Error with command: uvicorn rtm_app:app #1

Closed mohamedmehdigara closed 2 years ago

mohamedmehdigara commented 2 years ago

ERROR: Error loading ASGI app. Could not import module "rtm_app".

TaplierShiru commented 2 years ago

Hi! Did you wrote a command uvicorn rtm_app:app in the schat folder? I just tried it right now - and all seems good so far. Also, I forget to mention about chat page, it is - http://127.0.0.1:8000/chat by default, I will update README.

mohamedmehdigara commented 2 years ago

Hi! Yes and this is what I get: Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\uvicorn.exe\main__.py", line 7, in File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 829, in call return self.main(args, kwargs) File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 782, in main rv = self.invoke(ctx) File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 1066, in invoke return ctx.invoke(self.callback, ctx.params) File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\click\core.py", line 610, in invoke return callback(args, kwargs) File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\uvicorn\main.py", line 426, in main run(app, kwargs) File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\uvicorn\main.py", line 452, in run server.run() File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\uvicorn\server.py", line 68, in run return asyncio.run(self.serve(sockets=sockets)) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64qbz5n2kfra8p0\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64qbz5n2kfra8p0\lib\asyncio\base_events.py", line 642, in run_until_complete return future.result() File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\uvicorn\server.py", line 76, in serve config.load() File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\uvicorn\config.py", line 456, in load self.loaded_app = import_from_string(self.app) File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\uvicorn\importer.py", line 24, in import_from_string
raise exc from None File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\uvicorn\importer.py", line 21, in import_from_string
module = importlib.import_module(module_str) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64
qbz5n2kfra8p0\lib\importlib__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 850, in exec_module File "", line 228, in _call_with_frames_removed File "C:\Users\Admin\Downloads\FastAPI-and-Socket-io-SimpleChat\schat.\rtm_app.py", line 1, in import socketio ModuleNotFoundError: No module named 'socketio'

mohamedmehdigara commented 2 years ago

I am using Python2

TaplierShiru commented 2 years ago

Are you sure about Python2? Because I can clearly see Python3.9 in error lines, i.e. you are using Python3. The main issue here - you need to setup your python environment (install libs) with pip install -r requirements.txt in the main folder of this project. More info about python env, I think you can find in the Internet. Also, I update README, so you can read it again, if you had some questions before.