2013년 4월 25일 목요일

Openstack: How to solve pkg_resources.DistributionNotFound when executing glance


I installed and configured glance to try openstack grizzly. I followed the instruction from Grizzly install manual.
When I tried to create an image, I encountered the error and this was the error: 

$ sudo glance image-create --name="tty-linux-kernel" --disk-format=aki --container-format=aki < ttylinux-uec-amd64-12.1_2.6.35-22_1-vmlinuz
Traceback (most recent call last):
  File "/usr/bin/glance", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2711, in <module>
    parse_requirements(__requires__), Environment()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 584, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: requests>=0.8.8

Glance has dependencies on other modules, for example, python-swiftclient, python-keystoneclient and so on.
Even, python-swiftclient which installed here has dependencies on its own.
In order to get a clue to solve the error, I printed the command "glance"

$ cat /usr/bin/glance
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'python-glanceclient==0.9.0','console_scripts','glance'
__requires__ = 'python-glanceclient==0.9.0'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
    sys.exit(
        load_entry_point('python-glanceclient==0.9.0', 'console_scripts', 'glance')()
    )

It seemed that it was something wrong with modules related to "python-glanceclient". Next, I looked at /usr/lib/python2.7/dist-packages/python_glanceclient-0.9.0.egg-info/requires.txt file.
requires.txt fie is used to write a list of packages to install.

$ vi /usr/lib/python2.7/dist-packages/python_glanceclient-0.9.0.egg-info/requires.txt
prettytable&gh;=0.6,<0.8
python-keystoneclient>=0.2.3
pyOpenSSL
warlock>=0.7.0,<2

But, there was NO module named "requests" in here, so I tried to do other files which were indicated here. I opened the next file, requires.txt for keystoneclient.

$ vi /usr/lib/python2.7/dist-packages/python_keystoneclient-0.2.3.egg-info/requires.txt
iso8601>=0.1.4
prettytable
requests>=0.8.8
simplejson
oslo.config>=1.1.0

I finally found "request" in here and I checked the version of my request module to compare the version number.

$ sudo dpkg -l | grep request
ii  python-requests                      0.8.2-1                                  elegant and simple HTTP library for Python, built for human beings

My python-requests module was 0.8.2. I changed it into:

$ vi /usr/lib/python2.7/dist-packages/python_keystoneclient-0.2.3.egg-info/requires.txt
iso8601>=0.1.4
prettytable
requests>=0.8.2
simplejson
oslo.config>=1.1.0

I was able to solve my problem by doing this. However, I got another problem with this.

$ sudo glance image-create --name="tty-linux-kernel" --disk-format=aki --container-format=aki --file=ttylinux-uec-amd64-12.1_2.6.35-22_1-vmlinuz
Authorization Failed: request() got an unexpected keyword argument 'verify'

This was caused because I had old-dated "python-requests", I needed to install 0.8.8 or higher to work "verify". I found how to solve from the site: https://answers.launchpad.net/keystone/+question/218143

"this duo to you OS has a low version of python-requests by defalut,now python-keystoneclient require a python-requests>0.8.8,<1.0 this bug has been fixed to master. you can first git pull the lastest python-keystoneclient code. then run pip install -r tools/pip-requires."
I downloaded new version of it from https://pypi.python.org/pypi/requests/1.2.0
$ sudo tar -xzvf ./requests-1.2.0.tar.gz 
$ cd requests-1.2.0
$ sudo ./setup.py build

Finally it worked.

References: 
1. http://pedrojimenez.github.io/blog/2012/12/12/ubuntu-python-keystoneclient-dependency-error/
2. https://answers.launchpad.net/keystone/+question/218143
3. http://www.pip-installer.org/en/latest/requirements.html
   

댓글 2개:

  1. hi Yeonki,
    Your above post was most useful.. I was getting the same errors and solved them as u said.. but now I am getting another as :

    __init__() got an unexpected keyword argument 'insecure'

    this happens when I try to create an image via glance create-image command..
    Can you help me in this regard ? I have tried many things but nothing seems to solve this error..

    Thanks
    Nitisha

    답글삭제
  2. Hi, Nitisha.
    You already posted this issue on launchpad. (https://answers.launchpad.net/glance/+question/229213)

    I'll check it if I get the same error with you in case of executing "create-image". If so, I'll comment it.

    Thanks for visiting my blog.

    답글삭제

Related Posts Plugin for WordPress, Blogger...