Runtimeerror uvloop does not support windows at the moment

ERROR when running pip. It is written nowhere in readme that windows isn’t supported.

Collecting uvloop
  Downloading uvloop-0.14.0.tar.gz (2.0 MB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\xxx\anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\TENSOR~1\\AppData\\Local\\Temp\\pip-install-7kabq3oo\\uvloop\\setup.py'"'"'; __file__='"'"'C:\\Users\\TENSOR~1\\AppData\\Local\\Temp\\pip-install-7kabq3oo\\uvloop\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\TENSOR~1\AppData\Local\Temp\pip-install-7kabq3oo\uvloop\pip-egg-info'
         cwd: C:\Users\TENSOR~1\AppData\Local\Temp\pip-install-7kabq3oo\uvloop\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\TENSOR~1\AppData\Local\Temp\pip-install-7kabq3oo\uvloop\setup.py", line 15, in <module>
        raise RuntimeError('uvloop does not support Windows at the moment')
    RuntimeError: uvloop does not support Windows at the moment
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.```

Thank you! After having made several tests and having read again the documentation of uvicorn.

Everything was a little bit my fault

I launched the uvicorn HTTP server (without the --reload option) directly from the command line from a terminal (in my case Powershell), I got the error.

error connecting in 'pool-1': Psycopg cannot use the 'ProactorEventLoop' to run in async mode. Please use a compatible event loop, for instance by setting 'asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())'

Because this way of doing things didn’t read the import I had done in my main.py file, but simply started the server without caring about anything, hence the error asking me to set the event loop policy to WindowsSelectorEventLoopPolicy (which I had done), simply because the import line defining my event loop policy was never reached.

So now instead of launching my uvicorn server directly in the terminal like this

uvicorn src.main:app --port 2314

I execute my python code like this

python -m src.main

and I had to modify my code in main.py like this

import asyncio
from asyncio import WindowsSelectorEventLoopPolicy

import uvicorn
from fastapi import FastAPI
...

asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())


app = FastAPI()

...

if __name__ == '__main__':
    uvicorn.run('src.main:app', host="127.0.0.1", port=2314)

The reason why it was working without any problem in the terminal is by running my HTTP server with the --reload option like this

uvicorn src.main:app --port 2314 --reload

is that as @marcelo-trylesinski said, the --reload option automatically sets event loop to WindowsSelectorEventLoopPolicy. I wish this could be notified / mentioned in the documentation.

Thanks again to @marcelo-trylesinski for his help

Я запускаю команду pip install uvloop в cmd, окна выкидывают:

ERROR: Command errored out with exit status 1:
  command: 'c:\users\aaa\appdata\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\aaa\\AppData\\Local\\Temp\\pip-install-3c9w11a3\\uvloop\\setup.py'"'"'; __file__='"'"'C:\\Users\\aaa\\AppData\\Local\\Temp\\pip-install-3c9w11a3\\uvloop\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\aaa\AppData\Local\Temp\pip-pip-egg-info-m1b4rltp'
       cwd: C:\Users\aaa\AppData\Local\Temp\pip-install-3c9w11a3\uvloop\
  Complete output (5 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\aaa\AppData\Local\Temp\pip-install-3c9w11a3\uvloop\setup.py", line 15, in <module>
      raise RuntimeError('uvloop does not support Windows at the moment')
  RuntimeError: uvloop does not support Windows at the moment
  ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Я использую windows 10, Pip версии 20.1

2020-05-05 19:45

Recommend Projects

  • React photo
    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo
    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo
    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo
    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo
    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo
    Laravel

    A PHP framework for web artisans

  • D3 photo
    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 photo
    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo
    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo
    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo
    Alibaba

    Alibaba Open Source for everyone

  • D3 photo
    D3

    Data-Driven Documents codes.

  • Tencent photo
    Tencent

    China tencent open source team.

# Understand CGI

CGI (General Gateway Interface, Common Gateway Interface / CGI), defines a program that defines the communication method of the client and the web server.

# What is WSGI

PythonWeb Server Gateway interface (Python Web Server Gateway Interface) is an interface between Python applications or frames and web servers, has been widely accepted, which has basically reached its portability goals.
WSGI has no official implementation because WSGI is more like a protocol. As long as these protocols are followed, the WSGI application can run on any server (Server), and vice versa.
The WSGI standard is defined in PEP 333 and is implemented by many frameworks, and the Django framework supports WSGI (3.0 or later versions also supports) interface protocols.

# What is ASGI

ASGI (Asynchronous Gateway Protocol Interface, Asynchronous Server Gateway Interface) A standard interface between network protocol services and Python applications that can handle multiple common protocol types.

WSGI is based on HTTP protocol mode, does not support WebSocket, and ASGI’s birth is to solve Python commonly used WSGI does not support some new protocol standards in the current web development. At the same time, ASGI’s support and WebSocket extension for WSGI’s original model, that is, ASGI is WSGI extension.

Django3.0 supported ASGi, when I did this practice in March 21, Django’s version was 3.1.7. 3.2bata version has also been released, install Django’s practice, 3.2 version should be the long-term support version, instant, More and more people writing asynchronous code on Django.

# heljoWorld:

from django.http import HttpResponse 
 
async def index(request):
    return HttpResponse("Hello, async Django!")

# I will try to deploy production environments with ASGI under Windows and Linux, and this will record the installation and configuration process in the Windows environment.

1. Download Nginx, the latest Stable version is 1.18.0, link http://nginx.org/download/nginx-1.18.0.zip

2. There is no need to install, green, and unzip it under a folder, and wait for the configuration.

3. Use the Django built-in development test server, the project can start, but in fact it does not really run asynchronously, follow the Django official manual, we need to start the project with Uvicorn. Manual link https://docs.djangoproject.com/en/3.1/howto/deployment/ASGi/uvicorn/

(env)$python -m pip install uvicorn gunicorn

Create a Django project, start the project with the Uvicorn:

(env)$ django-admin.py startproject hello_async
(ENV) $ GUNICORN HELLO_ASYNC.ASGI: Application -k Uvicorn.Workers.uvicornworker #django official manual method

I have an error:

Traceback (most recent call last):
File «D:\Python\Python39\lib\runpy.py», line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File «D:\Python\Python39\lib\runpy.py», line 87, in _run_code
exec(code, run_globals)
File «E:\PycharmProjects\django-async-views\env\Scripts\gunicorn.exe\__main__.py», line 4, in <module>
File «e:\pycharmprojects\django-async-views\env\lib\site-packages\gunicorn\app\wsgiapp.py», line 9, in <module>
from gunicorn.app.base import Application
File «e:\pycharmprojects\django-async-views\env\lib\site-packages\gunicorn\app\base.py», line 11, in <module>
from gunicorn import util
File «e:\pycharmprojects\django-async-views\env\lib\site-packages\gunicorn\util.py», line 9, in <module>
import fcntl
ModuleNotFoundError: No module named ‘fcntl’

Tip missing module «FCNT1», then try to install it

python -m pip install fcntl

Wrong

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
ERROR: Could not find a version that satisfies the requirement fcnt1
ERROR: No matching distribution found for fcntl

Try not using GUNICORN to manage Uvicorn.

uvicorn hello_async.asgi:application

show:

INFO:     Started server process [13780]
INFO:     Waiting for application startup.
INFO:     ASGI 'lifespan' protocol appears unsupported.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

Successfully run, can also be accessed by browsers.

Read the Uvicorn Manual, link https://www.uvicorn.org/deployment/, found this sentence

The following will start Gunicorn with four worker processes:

gunicorn -w 4 -k uvicorn.workers.UvicornWorker

The UvicornWorker implementation uses the uvloop and httptools implementations.uvicorn.
Webs.uvicornWorker method, you need to call UVLOOP, I try to install UVLOOP
python -m pip install  uvloop
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting uvloop
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/44/6e/0cb292e4e6ee1382e2ede458f90c94b4f990b261f738403ac45cb8183bc2/uvloop-0.15.2.tar.gz (2.1 MB)
    ERROR: Command errored out with exit status 1:
     command: 'E:\PycharmProjects\django-async-views\env\Scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\imxin\\AppData\\Local\\Temp\\pip-install-oe6i3vdn\\uvloop_633952133c054cf196bcdebbf2688263\\setup.py'"'"'; __file__='"'"'C:\\Users\\imxin\\AppData\\Local\\Temp\\pip-install-oe6i3vdn\\uvloop_633952133c054cf196bcdebbf2688263\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\imxin\AppData\Local\Temp\pip-pip-egg-info-dxbd5o6z'
         cwd: C:\Users\imxin\AppData\Local\Temp\pip-install-oe6i3vdn\uvloop_633952133c054cf196bcdebbf2688263\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\imxin\AppData\Local\Temp\pip-install-oe6i3vdn\uvloop_633952133c054cf196bcdebbf2688263\setup.py", line 8, in <module>
        raise RuntimeError('uvloop does not support Windows at the moment')
    RuntimeError: uvloop does not  Support windows at the moment # does not support Windows

: This can’t find the FCNTL module, although it doesn’t matter, it seems that according to the official method, sinceWorkers.uvicornWorker needs to call UVLOOP, but Uvloop does not support Windows,At present, it is impossible to deploy to Windows Server. I personally think that the brothers don’t have to try to fill the pit.

Summary:

Attempting to deploy Django3.1 under Windows, the deployment fails, why is it half of failure? Because the official documentation, Gunicorn is the easiest way to run and manage Uvicorn in the production environment, but for exampleGUNICORN -W 4 -K uvicorn.Workers.uvicornWorker When starting GUNICORN in four working processes,UvicornworkerUseuvloopandHTTPTools, UVLOOP modules do not support Windows. If you don't have to use Gunicorn, just use Uvicorn is successful, but this does not match the requirements of the production environment. 

  • Runtimebroker exe что это за процесс windows 10
  • Rust desk server установка windows
  • Run windows app on mac
  • Runtimebroker exe как отключить windows 10
  • Russian phonetic keyboard for windows 10