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

ImportError: cannot import name 'Middleware' from 'httpx.middleware' (Windows) #613

Closed
lpellis opened this issue Dec 6, 2019 · 9 comments
Closed

Comments

@lpellis
Copy link

@lpellis lpellis commented Dec 6, 2019

I'm getting the following error trying to import httpx on Windows (python 3.8 and python 3.7 tested)
ImportError: cannot import name 'Middleware' from 'httpx.middleware'

It seems to be due to httpx containing both a package (httpx/middleware/init.py) and a module (httpx/middleware.py) of the same name, which is probably not a good idea.
A fix would be to simply rename middleware.py to something else, but I'm kinda confused why it would load at all though for other people?

@lpellis

This comment has been minimized.

Copy link
Author

@lpellis lpellis commented Dec 6, 2019

Looking at it some more, it looks like it might be a build artifact? The middleware directory is not present in the sourcecode or in the tar.gz package, but if I look at the the .whl it is there. ( https://pypi.org/project/httpx/#files )

@florimondmanca

This comment has been minimized.

Copy link
Contributor

@florimondmanca florimondmanca commented Dec 6, 2019

@lpellis I think this was resolved as of 0.9.1, can you confirm?

@remarkov

This comment has been minimized.

Copy link

@remarkov remarkov commented Dec 6, 2019

@florimondmanca I just updated from 0.8.0 to 0.9.1 and got this problem. Downgrading to 0.8.0 fixed it. I also tried 0.9.0 but it's there too.

@lpellis

This comment has been minimized.

Copy link
Author

@lpellis lpellis commented Dec 6, 2019

It is still present in 0.9.1

@michaelschmit

This comment has been minimized.

Copy link

@michaelschmit michaelschmit commented Dec 6, 2019

I'm seeing this error as well running on a mac.

@petermorrow

This comment has been minimized.

Copy link

@petermorrow petermorrow commented Dec 6, 2019

I'm also seeing this error on Amazon Linux with httpx==0.9.1. Switching to 0.8.0 fixed it as well.

@Punizione

This comment has been minimized.

Copy link

@Punizione Punizione commented Dec 7, 2019

I'm running 0.9.1 on Windows and seeing this error, downgrading to 0.8.0 to fix it...
full error stacktrace:

Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import httpx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python36\lib\site-packages\httpx\__init__.py", line 2, in <module>
    from .api import delete, get, head, options, patch, post, put, request, stream
  File "C:\Python36\lib\site-packages\httpx\api.py", line 3, in <module>
    from .client import Client, StreamContextManager
  File "C:\Python36\lib\site-packages\httpx\client.py", line 8, in <module>
    from .auth import BasicAuth
  File "C:\Python36\lib\site-packages\httpx\auth.py", line 10, in <module>
    from .middleware import Middleware
ImportError: cannot import name 'Middleware'
>>> quit()
@florimondmanca

This comment has been minimized.

Copy link
Contributor

@florimondmanca florimondmanca commented Dec 7, 2019

Hi, seems this issue is resolved in v0.9.2 - thanks @tomchristie!

@tomchristie

This comment has been minimized.

Copy link
Member

@tomchristie tomchristie commented Dec 7, 2019

With a further uncaught issue resolved in 0.9.3. Phew. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.