Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named xxx #13

Open
zzxwill opened this issue May 11, 2015 · 4 comments
Open

ImportError: No module named xxx #13

zzxwill opened this issue May 11, 2015 · 4 comments

Comments

@zzxwill
Copy link

zzxwill commented May 11, 2015

Hi Praneet. In you file https://github.com/Juniper/contrail-heat/blob/master/contrail_heat/resources/vn_subnet.py, there is a line "from contrail_heat.resources import contrail". What I did is the same as you for the heat resource plugin, but I hit "ImportError: No module named def_heat_plugin.client" when I wrote "from def_heat_plugin.client import constants as const". Any suggestions? Thanks.

@praneetb
Copy link

Hi, what is def_heat_plugin? is it a resource under /usr/lib/heat/ ?
if you want to import it , put your new resource file under /usr/lib/python2.7/dist-packages/
let me know if it works ...

@zzxwill
Copy link
Author

zzxwill commented May 12, 2015

Hi Praneet. def_heat_plugin is a heat resource type plugin. Yes, I copied the package to /usr/lib/heat/.

It works if I put the plugin under /usr/lib/python2.6/site-packages/. But it's not way I'd like it to work.

According to the directions of Openstack Official Heat/Plugins wiki https://wiki.openstack.org/wiki/Heat/Plugins, we only need "To install a plugin, copy the Python modules to one of the configured plugin directories. Note that heat-engine must be restarted after this in order to load the new plugins." But I hit the issue if I don't copy the plugin to site-packages. Here is the directory tree of my plugin. Only modules in resource/cms/ are subclass of Resources.

---def_heat_plugin
| README.txt
| init.py
|
+---client
| def_client.py
| constants.py
| meta_client.py
| socks.py
| init.py
|
+---config
| def.conf
| logging.conf
|
+---resources
| | init.py
| |
| ---def
| def_server.py
| init.py

@praneetb
Copy link

Hi Zheng,
This looks like more of a python issue. You have to make sure that the
path you are putting your heat plugin files , it can be imported by python.
The default import path is "/usr/lib/python2.6/site-packages/", you have
explicitly tell python what path you want to import.

Try something this ...

import sys

sys.path.append( )

import Bar

On Tue, May 12, 2015 at 3:12 AM, Zheng Xi Zhou [email protected]
wrote:

Hi Praneet. def_heat_plugin is a heat resource type plugin. Yes, I copied
the package to /usr/lib/heat/.

It works if I put the plugin under /usr/lib/python2.6/site-packages/. But
it's not way I'd like it to work.

According to the directions of Openstack Official Heat/Plugins wiki
https://wiki.openstack.org/wiki/Heat/Plugins, we only need "To install a
plugin, copy the Python modules to one of the configured plugin
directories. Note that heat-engine must be restarted after this in order to
load the new plugins." But I hit the issue if I don't copy the plugin to
site-packages. Here is the directory tree of my plugin. Only modules in
resource/cms/ are subclass of Resources.

---def_heat_plugin
| README.txt
| init.py
|
+---client
| def_client.py
| constants.py
| meta_client.py
| socks.py
| init.py
|
+---config
| def.conf
| logging.conf
|
+---resources
| | init.py
| |
| ---def
| def_server.py
| init.py


Reply to this email directly or view it on GitHub
#13 (comment)
.

@zzxwill
Copy link
Author

zzxwill commented May 18, 2015

I've tried what you suggested, it worked! Thanks a lot:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants