Skip to content
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

Example Server Fails to Run with "ImportError: cannot import name 'InvalidURL'" #849

Closed
jimjkelly opened this issue Apr 12, 2016 · 3 comments
Labels

Comments

@jimjkelly
Copy link

Long story short

When following the simple example tutorial to run a server both in the docs (http://aiohttp.readthedocs.org/en/stable/web.html#run-a-simple-web-server) and on the site, the server fails to launch.

Expected behaviour

A running server.

Actual behaviour

An exception is raised due to an inability to import InvalidURL. Stack trace:

Traceback (most recent call last):
  File "asyncio.py", line 1, in <module>
    from aiohttp import web
  File "/usr/local/lib/python3.5/site-packages/aiohttp/__init__.py", line 7, in <module>
    from .protocol import *  # noqa
  File "/usr/local/lib/python3.5/site-packages/aiohttp/protocol.py", line 14, in <module>
    from . import errors, hdrs
  File "/usr/local/lib/python3.5/site-packages/aiohttp/errors.py", line 3, in <module>
    from asyncio import TimeoutError
  File "/code/asyncio.py", line 1, in <module>
    from aiohttp import web
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web.py", line 7, in <module>
    from . import web_reqrep
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_reqrep.py", line 20, in <module>
    from .helpers import reify
  File "/usr/local/lib/python3.5/site-packages/aiohttp/helpers.py", line 15, in <module>
    from .errors import InvalidURL
ImportError: cannot import name 'InvalidURL'

It appears this is a circular import, so it's not surprising that it fails, but then I wonder how it works for other people? I even tried going back to older versions of aiohttp and get the same result. This implies EBKAC, but I'm not sure.

Steps to reproduce

Follow the simple example here: https://github.com/KeepSafe/aiohttp#server

Try and run the script from there.

Your environment

Python 3.5.1 from the official Python Docker Image. (https://github.com/docker-library/python/blob/764d302a21bd2442c2808bc802c95193b2cb8eea/3.5/Dockerfile)
pip install aiohttp (got version 0.21.5)

Thanks!

@asvetlov
Copy link
Member

Perhaps your own folder asyncio clashes with standard asyncio package.

File "/code/asyncio.py", line 1, in <module> looks very suspicious.

@jimjkelly
Copy link
Author

Well, aren't I red in the face. I knew there must be some EBKAC somewhere in here, and it's quite obvious once you point it out. Thanks, sorry for the dumb question!

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants