"ImportError: cannot import name types" when doing import oslo_config.cfg

Bug #1419585 reported by Ritesh
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
oslo.config
Invalid
Undecided
Unassigned

Bug Description

I am using a very simple publisher code (which is being called from pecan rest api to put a message onto rabbitmq)

The Code looks like this

import oslo_config.cfg # -->> This line gives the error
import oslo_messaging as messaging

class AttisProducer:
    log = logging.getLogger()
    def getTransport(self):
        configutil= ConfigurationUtil()
        transport_url = 'rabbit://attis:attis@192.168.56.105:5672/'
        transport = messaging.get_transport(cfg.CONF, transport_url)
        return transport

I get following error .

[Fri Feb 06 19:14:32.913660 2015] [:error] [pid 13029:tid 139988829513472] [remote 192.168.56.1:39606] from attis.common.messaging.producer import AttisProducer
[Fri Feb 06 19:14:32.913723 2015] [:error] [pid 13029:tid 139988829513472] [remote 192.168.56.1:39606] File "/opt/stack/venv/lib/python2.7/site-packages/attis_common-1.0.0a1-py2.7.egg/attis/common/messaging/producer.py", line 6, in <module>
[Fri Feb 06 19:14:32.914092 2015] [:error] [pid 13029:tid 139988829513472] [remote 192.168.56.1:39606] import oslo_config.cfg
[Fri Feb 06 19:14:32.914160 2015] [:error] [pid 13029:tid 139988829513472] [remote 192.168.56.1:39606] File "/opt/stack/venv/lib/python2.7/site-packages/oslo.config-1.6.0-py2.7.egg/oslo_config/cfg.py", line 334, in <module>
[Fri Feb 06 19:14:32.915013 2015] [:error] [pid 13029:tid 139988829513472] [remote 192.168.56.1:39606] from oslo.config import types
[Fri Feb 06 19:14:32.915098 2015] [:error] [pid 13029:tid 139988829513472] [remote 192.168.56.1:39606] ImportError: cannot import name types

dont know if i am doing anyting unusual

This is how my virtual env looks like (i am assuming this is due to some library incompatiblility )

root@managementnode:/home/shettyri# ls -lrta /opt/stack/venv/local/lib/python2.7/site-packages/
total 2632
drwxr-xr-x 4 root root 4096 Feb 6 08:12 ..
-rw-r--r-- 1 root root 126 Feb 6 08:12 easy_install.py
drwxr-xr-x 10 root root 4096 Feb 6 08:12 pip
drwxr-xr-x 2 root root 4096 Feb 6 08:12 pip-6.0.6.dist-info
-rw-r--r-- 1 root root 315 Feb 6 08:12 easy_install.pyc
drwxr-xr-x 2 root root 4096 Feb 6 08:12 _markerlib
drwxr-xr-x 4 root root 4096 Feb 6 08:12 setuptools
drwxr-xr-x 2 root root 4096 Feb 6 08:12 setuptools-11.0.dist-info
drwxr-xr-x 4 root root 4096 Feb 6 08:13 requests-2.5.1-py2.7.egg
-rw-r--r-- 1 root root 27915 Feb 6 08:13 prettytable-0.7.2-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:13 SQLAlchemy-0.9.8-py2.7-linux-x86_64.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:13 pecan-0.8.2-py2.7.egg
-rw-r--r-- 1 root root 15650 Feb 6 08:13 singledispatch-3.4.0.3-py2.7.egg
-rw-r--r-- 1 root root 41100 Feb 6 08:13 logutils-0.3.3-py2.7.egg
drwxr-xr-x 3 root root 4096 Feb 6 08:13 six-1.9.0-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:14 WebTest-2.0.18-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:14 Mako-1.0.1-py2.7.egg
-rw-r--r-- 1 root root 174638 Feb 6 08:14 WebOb-1.4-py2.7.egg
-rw-r--r-- 1 root root 170122 Feb 6 08:14 beautifulsoup4-4.3.2-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:14 waitress-0.8.9-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:14 MarkupSafe-0.23-py2.7-linux-x86_64.egg
-rw-r--r-- 1 root root 116947 Feb 6 08:14 MySQL_python-1.2.5-py2.7-linux-x86_64.egg
drwxr-xr-x 5 root root 4096 Feb 6 08:15 oslo.messaging-1.6.0-py2.7.egg
drwxr-xr-x 5 root root 4096 Feb 6 08:15 futures-2.2.0-py2.7.egg
drwxr-xr-x 5 root root 4096 Feb 6 08:15 oslo.middleware-0.4.0-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:15 kombu-3.0.24-py2.7.egg
-rw-r--r-- 1 root root 99016 Feb 6 08:15 PyYAML-3.11-py2.7-linux-x86_64.egg
drwxr-xr-x 5 root root 4096 Feb 6 08:15 eventlet-0.16.1-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:15 stevedore-1.2.0-py2.7.egg
drwxr-xr-x 5 root root 4096 Feb 6 08:16 oslo.i18n-1.3.1-py2.7.egg
drwxr-xr-x 5 root root 4096 Feb 6 08:16 oslo.serialization-1.2.0-py2.7.egg
drwxr-xr-x 5 root root 4096 Feb 6 08:16 oslo.utils-1.2.1-py2.7.egg
drwxr-xr-x 5 root root 4096 Feb 6 08:16 oslo.config-1.6.0-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:16 pbr-0.10.7-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:16 oslo.context-0.1.0-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:17 Babel-1.3-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:17 amqp-1.4.6-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:17 anyjson-0.3.3-py2.7.egg
drwxr-xr-x 3 root root 4096 Feb 6 08:17 greenlet-0.4.5-py2.7-linux-x86_64.egg
-rw-r--r-- 1 root root 13582 Feb 6 08:17 iso8601-0.1.10-py2.7.egg
-rw-r--r-- 1 root root 29318 Feb 6 08:17 netifaces-0.10.4-py2.7-linux-x86_64.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:17 netaddr-0.7.13-py2.7.egg
-rw-r--r-- 1 root root 477582 Feb 6 08:18 pytz-2014.10-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:18 ansible-1.8.2-py2.7.egg
-rw-r--r-- 1 root root 810488 Feb 6 08:18 pycrypto-2.6.1-py2.7-linux-x86_64.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:18 Jinja2-2.7.3-py2.7.egg
-rw-r--r-- 1 root root 361086 Feb 6 08:18 paramiko-1.15.2-py2.7.egg
-rw-r--r-- 1 root root 94674 Feb 6 08:18 ecdsa-0.12-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 08:19 cliff-1.9.0-py2.7.egg
drwxr-xr-x 3 root root 4096 Feb 6 08:19 pyparsing-2.0.3-py2.7.egg
-rw-r--r-- 1 root root 42135 Feb 6 08:19 cmd2-0.6.8-py2.7.egg
drwxr-xr-x 3 root root 4096 Feb 6 13:22 pkg_resources
drwxr-xr-x 4 root root 4096 Feb 6 18:55 attis_model-1.0.0a1-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 18:55 attis_common-1.0.0a1-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 18:55 attis_api-1.0.0a1-py2.7.egg
drwxr-xr-x 4 root root 4096 Feb 6 18:55 attis_server-1.0.0a1-py2.7.egg
-rw-r--r-- 1 root root 44 Feb 6 18:55 setuptools.pth
drwxr-xr-x 42 root root 4096 Feb 6 18:55 .
drwxr-xr-x 4 root root 4096 Feb 6 18:55 attis_cli-1.0.0a1-py2.7.egg
-rw-r--r-- 1 root root 1624 Feb 6 18:55 easy-install.pth

Revision history for this message
Ritesh (shetty-ritesh) wrote :

Also the types module is there as shown below

ls /opt/stack/venv/lib/python2.7/site-packages/oslo.config-1.6.0-py2.7.egg/oslo/config/
cfgfilter.py cfgfilter.pyc cfg.py cfg.pyc fixture.py fixture.pyc generator.py generator.pyc iniparser.py iniparser.pyc __init__.py __init__.pyc types.py types.pyc

Revision history for this message
Ritesh (shetty-ritesh) wrote :

Also was trying to track down the error line
/opt/stack/venv/lib/python2.7/site-packages/oslo.config-1.6.0-py2.7.egg/oslo_config/cfg.py", line 334,

"""

import argparse
import collections
import copy
import errno
import functools
import glob
import itertools
import logging
import os
import string
import sys

import six
from six import moves

from oslo.config import iniparser -->>>> This is line 334
from oslo.config import types

LOG = logging.getLogger(__name__)

class Error(Exception):
    """Base class for cfg exceptions."""

    def __init__(self, msg=None):
        self.msg = msg

    def __str__(self):
        return self.ms

Revision history for this message
Ritesh (shetty-ritesh) wrote :

Sorry gave a wrong line correcting it .......

Also was trying to track down the error line
/opt/stack/venv/lib/python2.7/site-packages/oslo.config-1.6.0-py2.7.egg/oslo_config/cfg.py", line 334,

"""

import argparse
import collections
import copy
import errno
import functools
import glob
import itertools
import logging
import os
import string
import sys

import six
from six import moves

from oslo.config import iniparser
from oslo.config import types -->>>> This is line 334

LOG = logging.getLogger(__name__)

class Error(Exception):
    """Base class for cfg exceptions."""

    def __init__(self, msg=None):
        self.msg = msg

    def __str__(self):
        return self.ms

Revision history for this message
Ritesh (shetty-ritesh) wrote :

ok after some googling found that due to some reason even through the oslo_config was being picked up from virtal env when it internally called oslo.config it went to my systems path
I followed fllowing solution(just changed to oslo config 1.6) and it worked !

https://bugs.launchpad.net/tripleo/+bug/1194807/comments/1

Revision history for this message
Ritesh (shetty-ritesh) wrote :

Dont think this is a bug , you can close it !

Revision history for this message
Longjie_Cao (grasson1101) wrote :

From you previous comment, there are no oslo_config directory under you virtual dev. If you call the oslo_config, it will go to your system path. I think you should install oslo_config to your virtual env, like using:
pip install oslo.config

Ian Cordasco (icordasc)
Changed in oslo.config:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.