New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'starlette.lifespan' #255

Closed
aiia opened this Issue Nov 29, 2018 · 11 comments

Comments

10 participants
@aiia
Copy link

aiia commented Nov 29, 2018

There's no lifespan module in the current 0.9.1 version of Starlette already.

@tomchristie

This comment has been minimized.

Copy link
Contributor

tomchristie commented Nov 29, 2018

Responder is pinned to Starlette 0.8 series, no?

https://github.com/kennethreitz/responder/blob/master/setup.py#L25

@aiia

This comment has been minimized.

Copy link

aiia commented Nov 29, 2018

I used Kenneth's pipenv for installation - and it delivered the recent Starlette.

@ranjanprj

This comment has been minimized.

Copy link

ranjanprj commented Nov 30, 2018

problem solved by using starlette 0.8 version

pip install starlette==0.8

@ibnesayeed

This comment has been minimized.

Copy link
Contributor

ibnesayeed commented Nov 30, 2018

Responder is pinned to Starlette 0.8 series, no?

Yes it is, but this change was made a few days after the last release v1.1.2, so the current latest release of responder in PyPi has broken dependencies as the 0.9 series of starlette (released a couple days ago) now handles lifespan as a middleware.

While, releasing a new version of the responder should fix this issue for now, but going forward the code should adapt to the change in the starlette about the lifespan or else we will be left with using an old code of a critical dependency.

@mass10

This comment has been minimized.

Copy link

mass10 commented Dec 2, 2018

👍

@hktalent

This comment has been minimized.

Copy link

hktalent commented Dec 10, 2018

in mac os @ranjanprj

pip3 install starlette==0.8
@theolampert

This comment has been minimized.

Copy link

theolampert commented Dec 13, 2018

@kennethreitz I think this should be reopened since it's still happening on a fresh install, following the readme:

pipenv install responder --pre
pipenv run python app.py

produces the following:

ModuleNotFoundError: No module named 'starlette.lifespan'
@jvalle3

This comment has been minimized.

Copy link

jvalle3 commented Dec 13, 2018

the same for me, same error on a fresh install

@jasonehines

This comment has been minimized.

Copy link

jasonehines commented Dec 13, 2018

Just installed and I'm also getting this.

@ibnesayeed

This comment has been minimized.

Copy link
Contributor

ibnesayeed commented Dec 13, 2018

These changes are merged, but not released yet. The last release was made on Nov 11, more than a month ago. Can you try installing from the development branch and see if the issue still exists?

$ pipenv install -e git+https://github.com/kennethreitz/responder.git#egg=responder
@nick-lehmann

This comment has been minimized.

Copy link

nick-lehmann commented Dec 22, 2018

I tried out what you proposed but I get a an AssertionError because of an exception in the lifespan protocol. The stacktrace is the following:

>>> pipenv run python webservice.py
INFO: Started server process [12156]
INFO: Waiting for application startup.
ERROR: Exception in 'lifespan' protocol
Traceback (most recent call last):
  File "/Volumes/Data/nick/.local/share/virtualenvs/quickstart-dTbPzXw9/lib/python3.6/site-packages/uvicorn/lifespan.py", line 29, in run
    await self.asgi(self.receive, self.send)
  File "/Volumes/Data/nick/.local/share/virtualenvs/quickstart-dTbPzXw9/lib/python3.6/site-packages/starlette/middleware/lifespan.py", line 68, in __call__
    await self.inner(receiver, send)
  File "/Volumes/Data/nick/.local/share/virtualenvs/quickstart-dTbPzXw9/src/responder/responder/api.py", line 228, in asgi
    req = models.Request(scope, receive=receive, api=self)
  File "/Volumes/Data/nick/.local/share/virtualenvs/quickstart-dTbPzXw9/src/responder/responder/models.py", line 97, in __init__
    self._starlette = StarletteRequest(scope, receive)
  File "/Volumes/Data/nick/.local/share/virtualenvs/quickstart-dTbPzXw9/lib/python3.6/site-packages/starlette/requests.py", line 119, in __init__
    super().__init__(scope)
  File "/Volumes/Data/nick/.local/share/virtualenvs/quickstart-dTbPzXw9/lib/python3.6/site-packages/starlette/requests.py", line 27, in __init__
    assert scope["type"] in ("http", "websocket")
AssertionError
ERROR: Application startup failed. Exiting.

The webservice.py script that I am running here is the basic example provided in the documentation, namely the following:

import responder

api = responder.API()


@api.route("/")
def hello_world(req, resp):
    resp.text = "hello world"


if __name__ == "__main__":
    api.run()

Before that, I freshly created the pipenv using the command you have proposed: pipenv install -e git+https://github.com/kennethreitz/responder.git#egg=responder and the installation itself worked just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment