Forum Archive

[SOLVED] 160025 - requests (and smtplib) module broken

userista
import requests
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/var/mobile/Containers/Bundle/Application/F7C28751-D087-40E9-BD22-C79FB689A145/Pythonista.app/pylib/site-packages/requests/__init__.py", line 53, in <module>
    from .packages.urllib3.contrib import pyopenssl
  File "/private/var/mobile/Containers/Bundle/Application/F7C28751-D087-40E9-BD22-C79FB689A145/Pythonista.app/pylib/site-packages/requests/packages/__init__.py", line 3, in <module>
    from . import urllib3
  File "/private/var/mobile/Containers/Bundle/Application/F7C28751-D087-40E9-BD22-C79FB689A145/Pythonista.app/pylib/site-packages/requests/packages/urllib3/__init__.py", line 11, in <module>
    from .connectionpool import (
  File "/private/var/mobile/Containers/Bundle/Application/F7C28751-D087-40E9-BD22-C79FB689A145/Pythonista.app/pylib/site-packages/requests/packages/urllib3/connectionpool.py", line 37, in <module>
    from .request import RequestMethods
  File "/private/var/mobile/Containers/Bundle/Application/F7C28751-D087-40E9-BD22-C79FB689A145/Pythonista.app/pylib/site-packages/requests/packages/urllib3/request.py", line 6, in <module>
    from .filepost import encode_multipart_formdata
  File "/private/var/mobile/Containers/Bundle/Application/F7C28751-D087-40E9-BD22-C79FB689A145/Pythonista.app/pylib/site-packages/requests/packages/urllib3/filepost.py", line 8, in <module>
    from .fields import RequestField
  File "/private/var/mobile/Containers/Bundle/Application/F7C28751-D087-40E9-BD22-C79FB689A145/Pythonista.app/pylib/site-packages/requests/packages/urllib3/fields.py", line 1, in <module>
    import email.utils
  File "/private/var/mobile/Containers/Shared/AppGroup/FA9B640E-6D58-4A63-B962-B8D73AEC123E/Documents/email.py", line 3
    import smtplib
                 ^
IndentationError: unindent does not match any outer indentation level
omz

Hmm, it looks like this is a side effect of the changed import path order. You apparently have a file named email.py in your documents – that is treated as a module and hides the standard library module of the same name.

For now, you can work around this by just renaming your own email.py file to something else, but I think I might need to make a change there, so that only things in site-packages can override library modules, but not things in the main documents folder...

userista

Oh you're right. Sorry about that

Webmaster4o

I'm also having some trouble with my script not seeing a file in the same folder as it. Another side effect?

omz

@Webmaster4o It's because of this: https://forum.omz-software.com/topic/2089/160025-import-from-same-directory/4 – will be fixed in the next build. Until then, you can use ywangd's workaround.

Webmaster4o

Saw that, thanks :)

Tizzy

I had the same issue. Workaround worked.