简体   繁体   中英

Getting python ImportError: cannot import name 'appengine'

I have single line in my py file:

from requests_toolbelt.multipart.encoder import MultipartEncoder

When I run it, I am getting following error:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests_toolbelt/_compat.py", line 49, in <module>
    from requests.packages.urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\workspaces\workspace6\Expe\Exp.py", line 8, in <module>
    from requests_toolbelt.multipart.encoder import MultipartEncoder
  File "/usr/lib/python3.6/site-packages/requests_toolbelt/__init__.py", line 12, in <module>
    from .adapters import SSLAdapter, SourceAddressAdapter
  File "/usr/lib/python3.6/site-packages/requests_toolbelt/adapters/__init__.py", line 12, in <module>
    from .ssl import SSLAdapter
  File "/usr/lib/python3.6/site-packages/requests_toolbelt/adapters/ssl.py", line 16, in <module>
    from .._compat import poolmanager
  File "/usr/lib/python3.6/site-packages/requests_toolbelt/_compat.py", line 51, in <module>
    from urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine'

I have just installed requests_toolbelt in cygwin on Windows:

$ pip3 install requests-toolbelt
Collecting requests-toolbelt
  Downloading https://files.pythonhosted.org/packages/97/8a/d710f792d6f6ecc089c5e55b66e66c3f2f35516a1ede5a8f54c13350ffb0/requests_toolbelt-0.8.0-py2.py3-none-any.whl (54kB)
    100% |████████████████████████████████| 61kB 841kB/s
Requirement already satisfied: requests<3.0.0,>=2.0.1 in /usr/lib/python3.6/site-packages (from requests-toolbelt)
Requirement already satisfied: urllib3==1.20 in /usr/lib/python3.6/site-packages (from requests<3.0.0,>=2.0.1->requests-toolbelt)
Installing collected packages: requests-toolbelt
Successfully installed requests-toolbelt-0.8.0
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Also note that I am running behind proxy.

I am running python 3.6.4:

$ python3
Python 3.6.4 (default, Jan  7 2018, 15:53:53)
[GCC 6.4.0] on cygwin

Considering all these, I am not sure why I am getting this error. Is it like requests_toolbelt have dependency appengine which is not installed? But it would have been installed while installing requests_toolbelt , right?

Update

I was getting above error when I am running the python file in eclipse with PyDev plugin. However I just tried running the same line through python shell >>> in cygwin command prompt and its giving same error.

Update 2

Tried installing same on python under Windows (not on cygwin) and it worked:

C:\Users\user1>pip  install requests-toolbelt
Collecting requests-toolbelt
  Downloading https://files.pythonhosted.org/packages/97/8a/d710f792d6f6ecc089c5e55b66e66c3f2f35516a1ede5a8f54c13350ffb0/requests_toolbelt-0.8.0-py2.py3-none-any.whl (54kB)
    100% |████████████████████████████████| 61kB 1.7MB/s
Collecting requests<3.0.0,>=2.0.1 (from requests-toolbelt)
  Downloading https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl (91kB)
    100% |████████████████████████████████| 92kB 1.9MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests<3.0.0,>=2.0.1->requests-toolbelt)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 2.4MB/s
Collecting urllib3<1.24,>=1.21.1 (from requests<3.0.0,>=2.0.1->requests-toolbelt)
  Downloading https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 2.4MB/s
Collecting certifi>=2017.4.17 (from requests<3.0.0,>=2.0.1->requests-toolbelt)
  Downloading https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl (150kB)
    100% |████████████████████████████████| 153kB 1.5MB/s
Collecting idna<2.8,>=2.5 (from requests<3.0.0,>=2.0.1->requests-toolbelt)
  Downloading https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 1.4MB/s
Installing collected packages: chardet, urllib3, certifi, idna, requests, requests-toolbelt
Successfully installed certifi-2018.4.16 chardet-3.0.4 idna-2.7 requests-2.19.1 requests-toolbelt-0.8.0 urllib3-1.23
You are using pip version 9.0.2, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

C:\Users\user1>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from requests_toolbelt.multipart.encoder import MultipartEncoder
>>>

Still guessing why it was not working on cygwin.

This seems to be an issue in requests_toolbelt which might be fixed in 0.7.1. Try to install newest version of it. https://github.com/mvantellingen/python-zeep/issues/413

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM