ubuntu trusty上的boto3(ImportError:没有名为packages.urllib3.exceptions的模块)

时间:2017-03-09 03:08:43

标签: python ubuntu boto3

我在Ubuntu Trusty上使用供应商提供的boto3时遇到问题。有没有其他人遇到过这个问题,如果是这样,你是如何解决的?

FWIW,boto3在同一台机器上的venv中工作正常,所以我认为这是一个包装问题。我需要在1000多台机器上提供boto3,因此需要使用供应商提供的软件包。

我尝试手动安装lxml,cssselect和request,如中所述 How to fix ImportError: No module named packages.urllib3?但这并没有解决问题。

谢谢,
杰弗里

vagrant@vagrant-ubuntu-trusty-64:~$ cat /etc/issue
Ubuntu 14.04.3 LTS \n \l

vagrant@vagrant-ubuntu-trusty-64:~$ sudo aptitude install python-boto3
....

vagrant@vagrant-ubuntu-trusty-64:~$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>> boto3.__version__
'1.2.2'
>>> boto3.resource('s3')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/boto3/__init__.py", line 87, in resource
    return _get_default_session().resource(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/boto3/session.py", line 292, in resource
    aws_session_token=aws_session_token, config=config)
  File "/usr/lib/python2.7/dist-packages/boto3/session.py", line 200, in client
    aws_session_token=aws_session_token, config=config)
  File "/usr/lib/python2.7/dist-packages/botocore/session.py", line 796, in create_client
    client_config=config, api_version=api_version)
  File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 59, in create_client
    cls = self._create_client_class(service_name, service_model)
  File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 76, in _create_client_class
    base_classes=bases)
  File "/usr/lib/python2.7/dist-packages/botocore/hooks.py", line 226, in emit
    return self._emit(event_name, kwargs)
  File "/usr/lib/python2.7/dist-packages/botocore/hooks.py", line 209, in _emit
    response = handler(**kwargs)
  File "/usr/lib/python2.7/dist-packages/boto3/utils.py", line 59, in _handler
    module = import_module(module)
  File "/usr/lib/python2.7/dist-packages/boto3/utils.py", line 52, in import_module
    __import__(name)
  File "/usr/lib/python2.7/dist-packages/boto3/s3/inject.py", line 13, in <module>
    from boto3.s3.transfer import S3Transfer
  File "/usr/lib/python2.7/dist-packages/boto3/s3/transfer.py", line 138, in <module>
    from requests.packages.urllib3.exceptions import ReadTimeoutError
ImportError: No module named packages.urllib3.exceptions

在同一台机器上,在venv中安装boto3似乎工作正常。 (至少我能够创建一个ServiceResource()对象。)

vagrant@vagrant-ubuntu-trusty-64:~$ virtualenv venv-boto3
New python executable in venv-boto3/bin/python
Installing setuptools, pip...done.

vagrant@vagrant-ubuntu-trusty-64:~$ source venv-boto3/bin/activate
(venv-boto3)vagrant@vagrant-ubuntu-trusty-64:~$ pip install boto3
Downloading/unpacking boto3
  Downloading boto3-1.4.4-py2.py3-none-any.whl (127kB): 127kB downloaded
...

(venv-boto3)vagrant@vagrant-ubuntu-trusty-64:~$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>> boto3.__version__
'1.4.4'
>>> boto3.resource('s3')
s3.ServiceResource()

0 个答案:

没有答案